类 JDateUtil


  • public class JDateUtil
    extends java.lang.Object
    • 构造器概要

      构造器 
      构造器 说明
      JDateUtil()  
    • 方法概要

      所有方法 静态方法 具体方法 
      修饰符和类型 方法 说明
      static java.util.Date asDate​(java.time.LocalDate localDate)
      Convert LocalDate to Date object.
      static java.util.Date asDate​(java.time.LocalDateTime localDateTime)
      Convert LocalDateTime to Date object.
      static java.time.LocalDate asLocalDate​(java.util.Date date)
      Convert Date to LocalDate object.
      static java.time.LocalDateTime asLocalDateTime​(long ms)
      Convert milli seconds to LocalDateTime object.
      static java.time.LocalDateTime asLocalDateTime​(java.util.Date date)
      Convert Date to LocalDateTime object.
      static long asMilliSeconds​(java.time.LocalDateTime ldt)
      Convert LocalDateTime to milli seconds
      static int dayOfYear​(int year, int month, int day)
      Get day of year
      static java.time.LocalDate doy2date​(int year, int doy)
      Convert day of year to date
      static boolean equals​(java.time.LocalDateTime a, java.time.LocalDateTime b)
      Date equals
      static java.time.LocalDateTime fromOADate​(double oaDate)
      Convert OA date to date
      static java.time.temporal.ChronoUnit getChronoUnit​(java.time.temporal.TemporalAmount ta)
      Get Chrono unit
      static java.lang.String getDateFormat​(java.time.temporal.TemporalAmount p)
      Get date format string
      static java.time.LocalDateTime getDateTime​(java.lang.String dts)
      Get date time from string
      static java.time.LocalDateTime getDateTime_​(java.lang.String dts)
      Get date time from string
      static java.util.List<java.time.LocalDateTime> getDateTimes​(int tNum, java.time.LocalDateTime end, java.time.temporal.TemporalAmount p)
      Get date time list
      static java.util.List<java.time.LocalDateTime> getDateTimes​(java.time.LocalDateTime start, int tNum, java.time.temporal.TemporalAmount p)
      Get date time list
      static java.util.List<java.time.LocalDateTime> getDateTimes​(java.time.LocalDateTime start, java.time.LocalDateTime end, java.time.temporal.TemporalAmount p)
      Get date time list
      static int getDays​(java.time.LocalDateTime t, java.time.LocalDateTime baseDate)
      Get days difference between two dates
      static int getDaysOfMonth​(int year, int month)
      Get days of a month
      static int getDaysOfYear​(int year)
      Get days of a year
      static int getHours​(java.time.LocalDateTime t, java.time.LocalDateTime baseDate)
      Get hours difference between two dates
      static java.time.temporal.TemporalAmount getPeriod​(java.lang.String pStr)
      Get period from string
      static java.time.temporal.ChronoUnit getPeriodType​(java.lang.String p)
      Get period type from string
      static int getTimeDeltaValue​(java.time.LocalDateTime t, java.time.LocalDateTime baseDate, java.lang.String tDelta)
      Get time value - Time delta value of base date
      static java.util.List<java.lang.Integer> getTimeDeltaValues​(java.util.List<java.time.LocalDateTime> times, java.time.LocalDateTime baseDate, java.lang.String tDelta)
      Get time values - Time delta values of base date
      static java.time.LocalDateTime parseDateTime​(java.lang.String dtStr, java.time.format.DateTimeFormatter formatter)
      Parse string to LocalDateTime
      static double toOADate​(java.time.LocalDateTime ldt)
      Convert LocalDateTime to OA date
      • 从类继承的方法 java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • 构造器详细资料

      • JDateUtil

        public JDateUtil()
    • 方法详细资料

      • asDate

        public static java.util.Date asDate​(java.time.LocalDate localDate)
        Convert LocalDate to Date object.
        参数:
        localDate - The LocalDate object.
        返回:
        Date object.
      • asDate

        public static java.util.Date asDate​(java.time.LocalDateTime localDateTime)
        Convert LocalDateTime to Date object.
        参数:
        localDateTime - The LocalDateTime object.
        返回:
        Date object.
      • asLocalDate

        public static java.time.LocalDate asLocalDate​(java.util.Date date)
        Convert Date to LocalDate object.
        参数:
        date - The Date object.
        返回:
        LocalDate object.
      • asLocalDateTime

        public static java.time.LocalDateTime asLocalDateTime​(java.util.Date date)
        Convert Date to LocalDateTime object.
        参数:
        date - The Date object.
        返回:
        LocalDateTime object.
      • asLocalDateTime

        public static java.time.LocalDateTime asLocalDateTime​(long ms)
        Convert milli seconds to LocalDateTime object.
        参数:
        ms - The milli seconds.
        返回:
        LocalDateTime object.
      • fromOADate

        public static java.time.LocalDateTime fromOADate​(double oaDate)
        Convert OA date to date
        参数:
        oaDate - OA date
        返回:
        Date
      • asMilliSeconds

        public static long asMilliSeconds​(java.time.LocalDateTime ldt)
        Convert LocalDateTime to milli seconds
        参数:
        ldt - Local date time
        返回:
        Milli seconds
      • toOADate

        public static double toOADate​(java.time.LocalDateTime ldt)
        Convert LocalDateTime to OA date
        参数:
        ldt - Local date time
        返回:
        OA date
      • getDaysOfMonth

        public static int getDaysOfMonth​(int year,
                                         int month)
        Get days of a month
        参数:
        year - The year
        month - The month
        返回:
        The days in the month
      • getDaysOfYear

        public static int getDaysOfYear​(int year)
        Get days of a year
        参数:
        year - The year
        返回:
        The days in the year
      • getTimeDeltaValues

        public static java.util.List<java.lang.Integer> getTimeDeltaValues​(java.util.List<java.time.LocalDateTime> times,
                                                                           java.time.LocalDateTime baseDate,
                                                                           java.lang.String tDelta)
        Get time values - Time delta values of base date
        参数:
        times - Time list
        baseDate - Base date
        tDelta - Time delta type - days/hours/...
        返回:
        The time delta values
      • getTimeDeltaValue

        public static int getTimeDeltaValue​(java.time.LocalDateTime t,
                                            java.time.LocalDateTime baseDate,
                                            java.lang.String tDelta)
        Get time value - Time delta value of base date
        参数:
        t - The time
        baseDate - Base date
        tDelta - Time delta type - days/hours/...
        返回:
        The time delta value
      • getDays

        public static int getDays​(java.time.LocalDateTime t,
                                  java.time.LocalDateTime baseDate)
        Get days difference between two dates
        参数:
        t - The time
        baseDate - Base date
        返回:
        The time delta value
      • getHours

        public static int getHours​(java.time.LocalDateTime t,
                                   java.time.LocalDateTime baseDate)
        Get hours difference between two dates
        参数:
        t - The time
        baseDate - Base date
        返回:
        The time delta value
      • equals

        public static boolean equals​(java.time.LocalDateTime a,
                                     java.time.LocalDateTime b)
        Date equals
        参数:
        a - Date a
        b - Date b
        返回:
        If equals
      • dayOfYear

        public static int dayOfYear​(int year,
                                    int month,
                                    int day)
        Get day of year
        参数:
        year - Year
        month - Month
        day - Day
        返回:
        Day of year
      • doy2date

        public static java.time.LocalDate doy2date​(int year,
                                                   int doy)
        Convert day of year to date
        参数:
        year - Year
        doy - Day of year
        返回:
        The date
      • getPeriodType

        public static java.time.temporal.ChronoUnit getPeriodType​(java.lang.String p)
        Get period type from string
        参数:
        p - Period type string
        返回:
        PeriodType
      • getPeriod

        public static java.time.temporal.TemporalAmount getPeriod​(java.lang.String pStr)
        Get period from string
        参数:
        pStr - Period string
        返回:
        Period
      • getChronoUnit

        public static java.time.temporal.ChronoUnit getChronoUnit​(java.time.temporal.TemporalAmount ta)
        Get Chrono unit
        参数:
        ta - The Temporal amount
        返回:
        Chrono unit
      • getDateFormat

        public static java.lang.String getDateFormat​(java.time.temporal.TemporalAmount p)
        Get date format string
        参数:
        p - Period
        返回:
        Date format string
      • getDateTime

        public static java.time.LocalDateTime getDateTime​(java.lang.String dts)
        Get date time from string
        参数:
        dts - Date time string
        返回:
        DateTime
      • getDateTime_

        public static java.time.LocalDateTime getDateTime_​(java.lang.String dts)
        Get date time from string
        参数:
        dts - Date time string
        返回:
        DateTime
      • getDateTimes

        public static java.util.List<java.time.LocalDateTime> getDateTimes​(java.time.LocalDateTime start,
                                                                           java.time.LocalDateTime end,
                                                                           java.time.temporal.TemporalAmount p)
        Get date time list
        参数:
        start - Start date time
        end - End date time
        p - Peroid
        返回:
        Date time list
      • getDateTimes

        public static java.util.List<java.time.LocalDateTime> getDateTimes​(java.time.LocalDateTime start,
                                                                           int tNum,
                                                                           java.time.temporal.TemporalAmount p)
        Get date time list
        参数:
        start - Start date time
        tNum - Date time number
        p - Peroid
        返回:
        Date time list
      • getDateTimes

        public static java.util.List<java.time.LocalDateTime> getDateTimes​(int tNum,
                                                                           java.time.LocalDateTime end,
                                                                           java.time.temporal.TemporalAmount p)
        Get date time list
        参数:
        end - End date time
        tNum - Date time number
        p - Peroid
        返回:
        Date time list
      • parseDateTime

        public static java.time.LocalDateTime parseDateTime​(java.lang.String dtStr,
                                                            java.time.format.DateTimeFormatter formatter)
        Parse string to LocalDateTime
        参数:
        dtStr - The string
        formatter - DateTimeFormatter
        返回:
        LocalDateTime