Class DateUtil


  • public class DateUtil
    extends java.lang.Object
    Utility for Date.
    • Field Summary

      Fields 
      Modifier and Type Field Description
      static java.lang.String HHMMSS
      HHmmss (e.g. 164225)
      static java.lang.String HHMMSS_TIME
      HH:mm:ss (e.g. 16:42:25)
      static java.lang.String HHMMSSSSS
      HHmmssSSS (e.g. 164225611)
      static java.lang.String ISO_LOCAL_DATE
      ISO_LOCAL_DATE (e.g. 2016-04-20)
      static java.lang.String ISO_LOCAL_DATE_TIME
      ISO_LOCAL_DATE_TIME (e.g. 2016-04-20T16:42:25.611)
      static java.lang.String ISO_LOCAL_TIME
      ISO_LOCAL_TIME (e.g. 16:42:25.611)
      static java.lang.String ISO_ZONED_DATE_TIME
      ISO_ZONED_DATE_TIME (e.g. 2016-04-20T16:42:25.611+09:00[Asia/Tokyo])
      static java.lang.String MM
      MM (e.g. 04)
      static java.lang.String UU
      uu (e.g. 16)
      static java.lang.String UUMM
      uuMM (e.g. 1604)
      static java.lang.String UUUU
      uuuu (e.g. 2016)
      static java.lang.String UUUUMM
      uuuuMM (e.g. 201604)
      static java.lang.String UUUUMM_HYPHEN
      uuuu-MM (e.g. 2016-04)
      static java.lang.String UUUUMM_SLASH
      uuuu/MM (e.g. 2016/04)
      static java.lang.String UUUUMMDD
      uuuuMMdd (e.g. 20160420)
      static java.lang.String UUUUMMDD_SLASH
      uuuu/MM/dd (e.g. 2016/04/20)
      static java.lang.String UUUUMMDDHHMM
      uuuuMMddHHmm (e.g. 201604201642)
      static java.lang.String UUUUMMDDHHMM_HYPHEN
      uuuu-MM-dd HHmm (e.g. 2016-04-20 16:42)
      static java.lang.String UUUUMMDDHHMM_SLASH
      uuuu/MM/dd HHmm (e.g. 2016/04/20 16:42)
      static java.lang.String UUUUMMDDHHMMSS
      uuuuMMddHHmmss (e.g. 20160420164225)
      static java.lang.String UUUUMMDDHHMMSS_HYPHEN
      uuuu-MM-dd HH:mm:ss (e.g. 2016-04-20 16:42:25)
      static java.lang.String UUUUMMDDHHMMSS_SLASH
      uuuu/MM/dd HH:mm:ss (e.g. 2016/04/20 16:42:25)
      static java.lang.String UUUUMMDDHHMMSSSSS
      uuuuMMddHHmmssSSS (e.g. 20160420164225611)
      static java.lang.String UUUUMMDDHHMMSSSSS_HYPHEN
      uuuu-MM-dd HH:mm:ss.SSS (e.g. 2016-04-20 16:42:25.611)
      static java.lang.String UUUUMMDDHHMMSSSSS_SLASH
      uuuu/MM/dd HH:mm:ss.SSS (e.g. 2016/04/20 16:42:25.611)
    • Constructor Summary

      Constructors 
      Constructor Description
      DateUtil()  
    • Method Summary

      All Methods Static Methods Concrete Methods 
      Modifier and Type Method Description
      static boolean isIntime​(java.util.Date start, java.util.Date end, java.util.Date target)
      Check if the date is in the specified period.
      static java.util.Calendar nowCalendar​(java.lang.String timeZone)
      Get system date
      static java.util.Date nowDate​(java.lang.String timeZone)
      Get system date
      static java.time.LocalDate nowLocalDate​(java.lang.String timeZone)
      Get system date
      static java.time.LocalDateTime nowLocalDateTime​(java.lang.String timeZone)
      Get system date
      static java.time.LocalTime nowLocalTime​(java.lang.String timeZone)
      Get system date
      static java.lang.String nowString​(java.lang.String format, java.lang.String timeZone)
      Get system date
      static java.time.YearMonth nowYearMonth​(java.lang.String timeZone)
      Get system date
      static java.time.ZonedDateTime nowZonedDateTime​(java.lang.String timeZone)
      Get system date
      static java.util.Calendar toCalendar​(java.lang.String str, java.lang.String format)
      Convert String to Calendar.
      static java.util.Calendar toCalendar​(java.time.LocalDate localDate)
      Convert LocalDate to Calendar.
      static java.util.Calendar toCalendar​(java.time.LocalDateTime localDateTime)
      Convert LocalDateTime to Calendar.
      static java.util.Calendar toCalendar​(java.time.LocalTime localTime, java.lang.String timeZone)
      Convert LocalTime to Calendar.
      static java.util.Calendar toCalendar​(java.time.ZonedDateTime zonedDateTime)
      Convert ZonedDateTime to Calendar.
      static java.util.Calendar toCalendar​(java.time.ZonedDateTime zonedDateTime, java.lang.String timeZone)
      Convert ZonedDateTime to Calendar.
      static java.util.Calendar toCalendar​(java.util.Date date)
      Convert Date to Calendar.
      static java.util.Date toDate​(java.lang.String str, java.lang.String format)
      Convert String to Date.
      static java.util.Date toDate​(java.time.LocalDate localDate)
      Convert LocalDate to Date.
      static java.util.Date toDate​(java.time.LocalDateTime localDateTime)
      Convert LocalDateTime to Date.
      static java.util.Date toDate​(java.time.LocalTime localTime, java.lang.String timeZone)
      Convert LocalTime to Date.
      static java.util.Date toDate​(java.time.ZonedDateTime zonedDateTime)
      Convert ZonedDateTime to Date.
      static java.util.Date toDate​(java.time.ZonedDateTime zonedDateTime, java.lang.String timeZone)
      Convert ZonedDateTime to Date.
      static java.util.Date toDate​(java.util.Calendar cal)
      Convert Calendar to Date.
      static java.time.LocalDate toLocalDate​(java.lang.String str, java.lang.String format)
      Convert String to LocalDate.
      static java.time.LocalDate toLocalDate​(java.time.LocalDateTime localDateTime)
      Convert LocalDateTime to LocalDate.
      static java.time.LocalDate toLocalDate​(java.time.ZonedDateTime zonedDateTime)
      Convert ZonedDateTime to LocalDate.
      static java.time.LocalDate toLocalDate​(java.time.ZonedDateTime zonedDateTime, java.lang.String timeZone)
      Convert ZonedDateTime to LocalDate.
      static java.time.LocalDate toLocalDate​(java.util.Calendar cal)
      Convert Calendar to LocalDate.
      static java.time.LocalDate toLocalDate​(java.util.Date date)
      Convert Date to LocalDate.
      static java.time.LocalDateTime toLocalDateTime​(java.lang.String str, java.lang.String format)
      Convert String to LocalDateTime.
      static java.time.LocalDateTime toLocalDateTime​(java.time.LocalDate localDate)
      Convert LocalDate to LocalDateTime.
      static java.time.LocalDateTime toLocalDateTime​(java.time.LocalDateTime localDateTime, java.time.ZoneId from, java.time.ZoneId to)
      Convert LocalDateTime to LocalDateTime.
      static java.time.LocalDateTime toLocalDateTime​(java.time.LocalTime localTime, java.lang.String timeZone)
      Convert LocalTime to LocalDateTime.
      static java.time.LocalDateTime toLocalDateTime​(java.time.ZonedDateTime zonedDateTime)
      Convert ZonedDateTime to LocalDateTime.
      static java.time.LocalDateTime toLocalDateTime​(java.time.ZonedDateTime zonedDateTime, java.lang.String timeZone)
      Convert ZonedDateTime to LocalDateTime.
      static java.time.LocalDateTime toLocalDateTime​(java.util.Calendar cal)
      Convert Calendar to LocalDateTime.
      static java.time.LocalDateTime toLocalDateTime​(java.util.Date date)
      Convert Date to LocalDateTime.
      static java.time.LocalTime toLocalTime​(java.lang.String str, java.lang.String format)
      Convert String to LocalTime.
      static java.time.LocalTime toLocalTime​(java.time.LocalDateTime localDateTime)
      Convert LocalDateTime to LocalTime.
      static java.time.LocalTime toLocalTime​(java.time.ZonedDateTime zonedDateTime)
      Convert ZonedDateTime to LocalTime.
      static java.time.LocalTime toLocalTime​(java.time.ZonedDateTime zonedDateTime, java.lang.String timeZone)
      Convert ZonedDateTime to LocalTime.
      static java.time.LocalTime toLocalTime​(java.util.Date date)
      Convert Date to LocalTime.
      static java.lang.String toString​(java.time.LocalDate localDate, java.lang.String format)
      Convert LocalDate to String.
      static java.lang.String toString​(java.time.LocalDateTime localDateTime, java.lang.String format)
      Convert LocalDateTime to String.
      static java.lang.String toString​(java.time.LocalTime localTime, java.lang.String format)
      Convert LocalTime to String.
      static java.lang.String toString​(java.time.YearMonth yearMonth, java.lang.String format)
      Convert YearMonth to String.
      static java.lang.String toString​(java.time.ZonedDateTime zonedDateTime, java.lang.String format)
      Convert ZonedDateTime to String.
      static java.lang.String toString​(java.time.ZonedDateTime zonedDateTime, java.lang.String timeZone, java.lang.String format)
      Convert ZonedDateTime to String.
      static java.lang.String toString​(java.util.Calendar cal, java.lang.String format)
      Convert Calendar to String.
      static java.lang.String toString​(java.util.Date date, java.lang.String format)
      Convert Date to String.
      static java.time.YearMonth toYearMonth​(java.lang.String str, java.lang.String format)
      Convert String to YearMonth.
      static java.time.YearMonth toYearMonth​(java.util.Calendar cal)
      Convert Calendar to YearMonth.
      static java.time.ZonedDateTime toZonedDateTime​(java.lang.String str, java.lang.String formatWithTimeZone)
      Convert String to ZonedDateTime.
      static java.time.ZonedDateTime toZonedDateTime​(java.lang.String str, java.lang.String formatWithoutTimeZone, java.lang.String timeZone)
      Convert String to ZonedDateTime.
      static java.time.ZonedDateTime toZonedDateTime​(java.time.LocalDate localDate, java.lang.String timeZone)
      Convert LocalDate to ZonedDateTime.
      static java.time.ZonedDateTime toZonedDateTime​(java.time.LocalDateTime localDateTime, java.lang.String timeZone)
      Convert LocalDateTime to ZonedDateTime.
      static java.time.ZonedDateTime toZonedDateTime​(java.time.LocalTime localTime, java.lang.String timeZone)
      Convert LocalTime to ZonedDateTime.
      static java.time.ZonedDateTime toZonedDateTime​(java.time.ZonedDateTime zonedDateTime, java.lang.String timeZone)
      Convert ZonedDateTime to ZonedDateTime.
      static java.time.ZonedDateTime toZonedDateTime​(java.util.Calendar cal, java.lang.String timeZone)
      Convert Calendar to ZonedDateTime.
      static java.time.ZonedDateTime toZonedDateTime​(java.util.Date date, java.lang.String timeZone)
      Convert Date to ZonedDateTime.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Field Detail

      • ISO_ZONED_DATE_TIME

        public static final java.lang.String ISO_ZONED_DATE_TIME
        ISO_ZONED_DATE_TIME (e.g. 2016-04-20T16:42:25.611+09:00[Asia/Tokyo])
        See Also:
        Constant Field Values
      • ISO_LOCAL_DATE_TIME

        public static final java.lang.String ISO_LOCAL_DATE_TIME
        ISO_LOCAL_DATE_TIME (e.g. 2016-04-20T16:42:25.611)
        See Also:
        Constant Field Values
      • ISO_LOCAL_DATE

        public static final java.lang.String ISO_LOCAL_DATE
        ISO_LOCAL_DATE (e.g. 2016-04-20)
        See Also:
        Constant Field Values
      • ISO_LOCAL_TIME

        public static final java.lang.String ISO_LOCAL_TIME
        ISO_LOCAL_TIME (e.g. 16:42:25.611)
        See Also:
        Constant Field Values
      • UUUUMM

        public static final java.lang.String UUUUMM
        uuuuMM (e.g. 201604)
        See Also:
        Constant Field Values
      • UUUUMM_HYPHEN

        public static final java.lang.String UUUUMM_HYPHEN
        uuuu-MM (e.g. 2016-04)
        See Also:
        Constant Field Values
      • UUUUMM_SLASH

        public static final java.lang.String UUUUMM_SLASH
        uuuu/MM (e.g. 2016/04)
        See Also:
        Constant Field Values
      • UUUUMMDD

        public static final java.lang.String UUUUMMDD
        uuuuMMdd (e.g. 20160420)
        See Also:
        Constant Field Values
      • UUUUMMDD_SLASH

        public static final java.lang.String UUUUMMDD_SLASH
        uuuu/MM/dd (e.g. 2016/04/20)
        See Also:
        Constant Field Values
      • UUUUMMDDHHMM

        public static final java.lang.String UUUUMMDDHHMM
        uuuuMMddHHmm (e.g. 201604201642)
        See Also:
        Constant Field Values
      • UUUUMMDDHHMM_HYPHEN

        public static final java.lang.String UUUUMMDDHHMM_HYPHEN
        uuuu-MM-dd HHmm (e.g. 2016-04-20 16:42)
        See Also:
        Constant Field Values
      • UUUUMMDDHHMM_SLASH

        public static final java.lang.String UUUUMMDDHHMM_SLASH
        uuuu/MM/dd HHmm (e.g. 2016/04/20 16:42)
        See Also:
        Constant Field Values
      • UUUUMMDDHHMMSS

        public static final java.lang.String UUUUMMDDHHMMSS
        uuuuMMddHHmmss (e.g. 20160420164225)
        See Also:
        Constant Field Values
      • UUUUMMDDHHMMSS_HYPHEN

        public static final java.lang.String UUUUMMDDHHMMSS_HYPHEN
        uuuu-MM-dd HH:mm:ss (e.g. 2016-04-20 16:42:25)
        See Also:
        Constant Field Values
      • UUUUMMDDHHMMSS_SLASH

        public static final java.lang.String UUUUMMDDHHMMSS_SLASH
        uuuu/MM/dd HH:mm:ss (e.g. 2016/04/20 16:42:25)
        See Also:
        Constant Field Values
      • UUUUMMDDHHMMSSSSS

        public static final java.lang.String UUUUMMDDHHMMSSSSS
        uuuuMMddHHmmssSSS (e.g. 20160420164225611)
        See Also:
        Constant Field Values
      • UUUUMMDDHHMMSSSSS_HYPHEN

        public static final java.lang.String UUUUMMDDHHMMSSSSS_HYPHEN
        uuuu-MM-dd HH:mm:ss.SSS (e.g. 2016-04-20 16:42:25.611)
        See Also:
        Constant Field Values
      • UUUUMMDDHHMMSSSSS_SLASH

        public static final java.lang.String UUUUMMDDHHMMSSSSS_SLASH
        uuuu/MM/dd HH:mm:ss.SSS (e.g. 2016/04/20 16:42:25.611)
        See Also:
        Constant Field Values
      • HHMMSS_TIME

        public static final java.lang.String HHMMSS_TIME
        HH:mm:ss (e.g. 16:42:25)
        See Also:
        Constant Field Values
      • HHMMSS

        public static final java.lang.String HHMMSS
        HHmmss (e.g. 164225)
        See Also:
        Constant Field Values
      • HHMMSSSSS

        public static final java.lang.String HHMMSSSSS
        HHmmssSSS (e.g. 164225611)
        See Also:
        Constant Field Values
    • Constructor Detail

      • DateUtil

        public DateUtil()
    • Method Detail

      • nowZonedDateTime

        public static java.time.ZonedDateTime nowZonedDateTime​(java.lang.String timeZone)
        Get system date. (ZonedDateTime)
        Parameters:
        timeZone - ZoneId like UTC, JST, ECT, or Asia/Tokyo, Europe/Paris... (e.g. UTC)
        Returns:
        ZonedDateTime
      • nowLocalDateTime

        public static java.time.LocalDateTime nowLocalDateTime​(java.lang.String timeZone)
        Get system date. (LocalDateTime)
        Parameters:
        timeZone - ZoneId like UTC, JST, ECT, or Asia/Tokyo, Europe/Paris... (e.g. UTC)
        Returns:
        LocalDateTime
      • nowLocalDate

        public static java.time.LocalDate nowLocalDate​(java.lang.String timeZone)
        Get system date. (LocalDate)
        Parameters:
        timeZone - ZoneId like UTC, JST, ECT, or Asia/Tokyo, Europe/Paris... (e.g. UTC)
        Returns:
        LocalDate
      • nowLocalTime

        public static java.time.LocalTime nowLocalTime​(java.lang.String timeZone)
        Get system date. (LocalTime)
        Parameters:
        timeZone - ZoneId like UTC, JST, ECT, or Asia/Tokyo, Europe/Paris... (e.g. UTC)
        Returns:
        LocalTime
      • nowDate

        public static java.util.Date nowDate​(java.lang.String timeZone)
        Get system date. (Date)
        Parameters:
        timeZone - ZoneId like UTC, JST, ECT, or Asia/Tokyo, Europe/Paris... (e.g. UTC)
        Returns:
        Date
      • nowCalendar

        public static java.util.Calendar nowCalendar​(java.lang.String timeZone)
        Get system date. (Calendar)
        Parameters:
        timeZone - ZoneId like UTC, JST, ECT, or Asia/Tokyo, Europe/Paris... (e.g. UTC)
        Returns:
        Calendar
      • nowYearMonth

        public static java.time.YearMonth nowYearMonth​(java.lang.String timeZone)
        Get system date. (YearMonth)
        Parameters:
        timeZone - ZoneId like UTC, JST, ECT, or Asia/Tokyo, Europe/Paris... (e.g. UTC)
        Returns:
        YearMonth
      • nowString

        public static java.lang.String nowString​(java.lang.String format,
                                                 java.lang.String timeZone)
        Get system date. (String)
        Parameters:
        format - DateTimeFormatter.ofPattern(java.lang.String) (e.g. "uuuu/MM/dd HH:mm:ss")
        timeZone - ZoneId like UTC, JST, ECT, or Asia/Tokyo, Europe/Paris... (e.g. UTC)
        Returns:
        String
      • toZonedDateTime

        public static java.time.ZonedDateTime toZonedDateTime​(java.time.ZonedDateTime zonedDateTime,
                                                              java.lang.String timeZone)
        Convert ZonedDateTime to ZonedDateTime.
        Parameters:
        zonedDateTime - ZonedDateTime (e.g. 2016/04/19 23:00:00 +0000)
        timeZone - ZoneId like UTC, JST, ECT, or Asia/Tokyo, Europe/Paris... (e.g. JST)
        Returns:
        ZonedDateTime (e.g. 2016/04/20 08:00:00 +9000)
      • toZonedDateTime

        public static java.time.ZonedDateTime toZonedDateTime​(java.time.LocalDateTime localDateTime,
                                                              java.lang.String timeZone)
        Convert LocalDateTime to ZonedDateTime.
        Parameters:
        localDateTime - LocalDateTime (e.g. 2016/04/19 23:00:00)
        timeZone - ZoneId like UTC, JST, ECT, or Asia/Tokyo, Europe/Paris... (e.g. UTC)
        Returns:
        ZonedDateTime (e.g. 2016/04/19 23:00:00 +0000)
      • toZonedDateTime

        public static java.time.ZonedDateTime toZonedDateTime​(java.time.LocalDate localDate,
                                                              java.lang.String timeZone)
        Convert LocalDate to ZonedDateTime.
        Parameters:
        localDate - LocalDate (e.g. 2016/04/19)
        timeZone - ZoneId like UTC, JST, ECT, or Asia/Tokyo, Europe/Paris... (e.g. UTC)
        Returns:
        ZonedDateTime (e.g. 2016/04/19 00:00:00 +0000)
      • toZonedDateTime

        public static java.time.ZonedDateTime toZonedDateTime​(java.time.LocalTime localTime,
                                                              java.lang.String timeZone)
        Convert LocalTime to ZonedDateTime.
        Parameters:
        localTime - LocalTime (e.g. 23:00:00)
        timeZone - ZoneId like UTC, JST, ECT, or Asia/Tokyo, Europe/Paris... (e.g. UTC)
        Returns:
        ZonedDateTime (e.g. 2016/04/19 23:00:00 +0000, Date = LocalDate.now())
      • toZonedDateTime

        public static java.time.ZonedDateTime toZonedDateTime​(java.util.Date date,
                                                              java.lang.String timeZone)
        Convert Date to ZonedDateTime.

        e.g. If parameters are Date = 2016/04/19 23:00:00, timeZone = "UTC", returns 2016/04/19 23:00:00 +0000 (UTC)

        Parameters:
        date - Date (e.g. 2016/04/19 23:00:00)
        timeZone - ZoneId like UTC, JST, ECT, or Asia/Tokyo, Europe/Paris... (e.g. UTC)
        Returns:
        ZonedDateTime (e.g. 2016/04/19 23:00:00)
      • toZonedDateTime

        public static java.time.ZonedDateTime toZonedDateTime​(java.util.Calendar cal,
                                                              java.lang.String timeZone)
        Convert Calendar to ZonedDateTime.
        Parameters:
        cal - Calendar (e.g. 2016/04/19 23:00:00)
        timeZone - ZoneId like UTC, JST, ECT, or Asia/Tokyo, Europe/Paris... (e.g. UTC)
        Returns:
        ZonedDateTime (e.g. 2016/04/19 23:00:00 +0000)
      • toZonedDateTime

        public static java.time.ZonedDateTime toZonedDateTime​(java.lang.String str,
                                                              java.lang.String formatWithTimeZone)
        Convert String to ZonedDateTime.
        Parameters:
        str - String (e.g. 2016/04/19 23:00:00 +0000)
        formatWithTimeZone - DateTimeFormatter.ofPattern(java.lang.String) (e.g. "uuuu/MM/dd HH:mm:ss Z")
        Returns:
        ZonedDateTime (e.g. 2016/04/19 23:00:00 +0000)
      • toZonedDateTime

        public static java.time.ZonedDateTime toZonedDateTime​(java.lang.String str,
                                                              java.lang.String formatWithoutTimeZone,
                                                              java.lang.String timeZone)
        Convert String to ZonedDateTime.
        Parameters:
        str - String (e.g. 2016/04/19 23:00:00)
        formatWithoutTimeZone - DateTimeFormatter.ofPattern(java.lang.String) (e.g. "uuuu/MM/dd HH:mm:ss")
        timeZone - ZoneId like UTC, JST, ECT, or Asia/Tokyo, Europe/Paris... (e.g. UTC)
        Returns:
        ZonedDateTime (e.g. 2016/04/19 23:00:00 +0000)
      • toLocalDateTime

        public static java.time.LocalDateTime toLocalDateTime​(java.time.ZonedDateTime zonedDateTime,
                                                              java.lang.String timeZone)
        Convert ZonedDateTime to LocalDateTime.
        Parameters:
        zonedDateTime - ZonedDateTime (e.g. 2016/04/19 23:00:00 +0000)
        timeZone - ZoneId like UTC, JST, ECT, or Asia/Tokyo, Europe/Paris... (e.g. JST)
        Returns:
        LocalDateTime (e.g. 2016/04/20 08:00:00)
      • toLocalDateTime

        public static java.time.LocalDateTime toLocalDateTime​(java.time.ZonedDateTime zonedDateTime)
        Convert ZonedDateTime to LocalDateTime.
        Parameters:
        zonedDateTime - ZonedDateTime (e.g. 2016/04/19 23:00:00 +0000)
        Returns:
        LocalDateTime (e.g. 2016/04/19 23:00:00)
      • toLocalDateTime

        public static java.time.LocalDateTime toLocalDateTime​(java.time.LocalDateTime localDateTime,
                                                              java.time.ZoneId from,
                                                              java.time.ZoneId to)
        Convert LocalDateTime to LocalDateTime.
        Parameters:
        localDateTime - LocalDateTime (e.g. 2016/04/19 23:00:00)
        from - ZoneId like UTC.
        to - ZoneId like JST.
        Returns:
        LocalDateTime (e.g. 2016/04/19 08:00:00)
      • toLocalDateTime

        public static java.time.LocalDateTime toLocalDateTime​(java.time.LocalDate localDate)
        Convert LocalDate to LocalDateTime.
        Parameters:
        localDate - LocalDate (e.g. 2016/04/19)
        Returns:
        LocalDateTime (e.g. 2016/04/19 00:00:00)
      • toLocalDateTime

        public static java.time.LocalDateTime toLocalDateTime​(java.time.LocalTime localTime,
                                                              java.lang.String timeZone)
        Convert LocalTime to LocalDateTime.
        Parameters:
        localTime - LocalTime (e.g. 23:00:00)
        timeZone - ZoneId like UTC, JST, ECT, or Asia/Tokyo, Europe/Paris... (e.g. JST)
        Returns:
        LocalDateTime (e.g. 2016/04/19 23:00:00, Date = nowLocalDate())
      • toLocalDateTime

        public static java.time.LocalDateTime toLocalDateTime​(java.util.Date date)
        Convert Date to LocalDateTime.
        Parameters:
        date - Date (e.g. 2016/04/19 23:00:00)
        Returns:
        LocalDateTime (e.g. 2016/04/19 23:00:00)
      • toLocalDateTime

        public static java.time.LocalDateTime toLocalDateTime​(java.util.Calendar cal)
        Convert Calendar to LocalDateTime.
        Parameters:
        cal - Calendar (e.g. 2016/04/19 23:00:00)
        Returns:
        LocalDateTime (e.g. 2016/04/19 23:00:00)
      • toLocalDateTime

        public static java.time.LocalDateTime toLocalDateTime​(java.lang.String str,
                                                              java.lang.String format)
        Convert String to LocalDateTime.
        Parameters:
        str - String (e.g. "2016/04/19 23:00:00")
        format - DateTimeFormatter.ofPattern(java.lang.String) (e.g. "uuuu/MM/dd HH:mm:ss")
        Returns:
        LocalDateTime (e.g. 2016/04/19 23:00:00)
      • toLocalDate

        public static java.time.LocalDate toLocalDate​(java.time.ZonedDateTime zonedDateTime,
                                                      java.lang.String timeZone)
        Convert ZonedDateTime to LocalDate.
        Parameters:
        zonedDateTime - ZonedDateTime (e.g. 2016/04/19 23:00:00 +0000)
        timeZone - ZoneId like UTC, JST, ECT, or Asia/Tokyo, Europe/Paris... (e.g. JST)
        Returns:
        LocalDate (e.g. 2016/04/20)
      • toLocalDate

        public static java.time.LocalDate toLocalDate​(java.time.ZonedDateTime zonedDateTime)
        Convert ZonedDateTime to LocalDate.
        Parameters:
        zonedDateTime - ZonedDateTime (e.g. 2016/04/19 23:00:00 +0000)
        Returns:
        LocalDate (e.g. 2016/04/19)
      • toLocalDate

        public static java.time.LocalDate toLocalDate​(java.time.LocalDateTime localDateTime)
        Convert LocalDateTime to LocalDate.
        Parameters:
        localDateTime - LocalDateTime (e.g. 2016/04/19 23:00:00)
        Returns:
        LocalDate (e.g. 2016/04/19)
      • toLocalDate

        public static java.time.LocalDate toLocalDate​(java.util.Date date)
        Convert Date to LocalDate.
        Parameters:
        date - Date (e.g. 2016/04/19)
        Returns:
        LocalDate (e.g. 2016/04/19)
      • toLocalDate

        public static java.time.LocalDate toLocalDate​(java.util.Calendar cal)
        Convert Calendar to LocalDate.
        Parameters:
        cal - Calendar (e.g. 2016/04/19)
        Returns:
        LocalDate (e.g. 2016/04/19)
      • toLocalDate

        public static java.time.LocalDate toLocalDate​(java.lang.String str,
                                                      java.lang.String format)
        Convert String to LocalDate.
        Parameters:
        str - String (e.g. "2016/04/19")
        format - DateTimeFormatter.ofPattern(java.lang.String) (e.g. "uuuu/MM/dd")
        Returns:
        LocalDate (e.g. 2016/04/19)
      • toLocalTime

        public static java.time.LocalTime toLocalTime​(java.time.ZonedDateTime zonedDateTime,
                                                      java.lang.String timeZone)
        Convert ZonedDateTime to LocalTime.
        Parameters:
        zonedDateTime - ZonedDateTime (e.g. 2016/04/19 23:00:00 +0000)
        timeZone - ZoneId like UTC, JST, ECT, or Asia/Tokyo, Europe/Paris... (e.g. JST)
        Returns:
        LocalTime (e.g. 08:00:00)
      • toLocalTime

        public static java.time.LocalTime toLocalTime​(java.time.ZonedDateTime zonedDateTime)
        Convert ZonedDateTime to LocalTime.
        Parameters:
        zonedDateTime - ZonedDateTime (e.g. 2016/04/19 23:00:00 +0000)
        Returns:
        LocalTime (e.g. 23:00:00)
      • toLocalTime

        public static java.time.LocalTime toLocalTime​(java.time.LocalDateTime localDateTime)
        Convert LocalDateTime to LocalTime.
        Parameters:
        localDateTime - LocalDateTime (e.g. 2016/04/19 23:00:00)
        Returns:
        LocalTime (e.g. 23:00:00)
      • toLocalTime

        public static java.time.LocalTime toLocalTime​(java.util.Date date)
        Convert Date to LocalTime.
        Parameters:
        date - Date (e.g. 2016/04/19 23:00:00)
        Returns:
        LocalTime (e.g. 23:00:00)
      • toLocalTime

        public static java.time.LocalTime toLocalTime​(java.lang.String str,
                                                      java.lang.String format)
        Convert String to LocalTime.
        Parameters:
        str - String (e.g. "2016/04/19 23:00:00")
        format - DateTimeFormatter.ofPattern(java.lang.String) (e.g. "HH:mm:ss")
        Returns:
        LocalTime (e.g. 23:00:00)
      • toDate

        public static java.util.Date toDate​(java.time.ZonedDateTime zonedDateTime,
                                            java.lang.String timeZone)
        Convert ZonedDateTime to Date.
        Parameters:
        zonedDateTime - ZonedDateTime (e.g. 2016/04/19 23:00:00 +0000)
        timeZone - ZoneId like UTC, JST, ECT, or Asia/Tokyo, Europe/Paris... (e.g. JST)
        Returns:
        Date (e.g. 2016/04/20 08:00:00)
      • toDate

        public static java.util.Date toDate​(java.time.ZonedDateTime zonedDateTime)
        Convert ZonedDateTime to Date.
        Parameters:
        zonedDateTime - ZonedDateTime (e.g. 2016/04/19 23:00:00 +0000)
        Returns:
        Date (e.g. 2016/04/19 23:00:00)
      • toDate

        public static java.util.Date toDate​(java.time.LocalDateTime localDateTime)
        Convert LocalDateTime to Date.
        Parameters:
        localDateTime - LocalDateTime (e.g. 2016/04/19 23:00:00)
        Returns:
        Date (e.g. 2016/04/19 23:00:00)
      • toDate

        public static java.util.Date toDate​(java.time.LocalDate localDate)
        Convert LocalDate to Date.
        Parameters:
        localDate - LocalDate (e.g. 2016/04/19)
        Returns:
        Date (e.g. 2016/04/19 00:00:00)
      • toDate

        public static java.util.Date toDate​(java.time.LocalTime localTime,
                                            java.lang.String timeZone)
        Convert LocalTime to Date.
        Parameters:
        localTime - LocalTime (e.g. 23:00:00)
        timeZone - ZoneId like UTC, JST, ECT, or Asia/Tokyo, Europe/Paris... (e.g. JST)
        Returns:
        Date (e.g. 2016/04/19 23:00:00, Date = nowLocalDate())
      • toDate

        public static java.util.Date toDate​(java.util.Calendar cal)
        Convert Calendar to Date.
        Parameters:
        cal - Calendar (e.g. 2016/04/19 23:00:00)
        Returns:
        Date (e.g. 2016/04/19 23:00:00)
      • toDate

        public static java.util.Date toDate​(java.lang.String str,
                                            java.lang.String format)
        Convert String to Date.
        Parameters:
        str - String (e.g. "2016/04/19 23:00:00")
        format - DateTimeFormatter.ofPattern(java.lang.String) (e.g. "uuuu/MM/dd HH:mm:ss")
        Returns:
        Date (e.g. 2016/04/19 23:00:00)
      • toCalendar

        public static java.util.Calendar toCalendar​(java.time.ZonedDateTime zonedDateTime,
                                                    java.lang.String timeZone)
        Convert ZonedDateTime to Calendar.
        Parameters:
        zonedDateTime - ZonedDateTime (e.g. 2016/04/19 23:00:00 +0000)
        timeZone - ZoneId like UTC, JST, ECT, or Asia/Tokyo, Europe/Paris... (e.g. JST)
        Returns:
        Calendar (e.g. 2016/04/20 08:00:00)
      • toCalendar

        public static java.util.Calendar toCalendar​(java.time.ZonedDateTime zonedDateTime)
        Convert ZonedDateTime to Calendar.
        Parameters:
        zonedDateTime - ZonedDateTime (e.g. 2016/04/19 23:00:00 +0000)
        Returns:
        Calendar (e.g. 2016/04/19 23:00:00)
      • toCalendar

        public static java.util.Calendar toCalendar​(java.time.LocalDateTime localDateTime)
        Convert LocalDateTime to Calendar.
        Parameters:
        localDateTime - LocalDateTime (e.g. 2016/04/19 23:00:00)
        Returns:
        Calendar (e.g. 2016/04/19 23:00:00)
      • toCalendar

        public static java.util.Calendar toCalendar​(java.time.LocalDate localDate)
        Convert LocalDate to Calendar.
        Parameters:
        localDate - LocalDate (e.g. 2016/04/19)
        Returns:
        Calendar (e.g. 2016/04/19 00:00:00)
      • toCalendar

        public static java.util.Calendar toCalendar​(java.time.LocalTime localTime,
                                                    java.lang.String timeZone)
        Convert LocalTime to Calendar.
        Parameters:
        localTime - LocalTime (e.g. 23:00:00)
        timeZone - ZoneId like UTC, JST, ECT, or Asia/Tokyo, Europe/Paris... (e.g. JST)
        Returns:
        Calendar (e.g. 2016/04/19 23:00:00, Date = nowLocalDate())
      • toCalendar

        public static java.util.Calendar toCalendar​(java.util.Date date)
        Convert Date to Calendar.
        Parameters:
        date - Date (e.g. 2016/04/19 23:00:00)
        Returns:
        Calendar (e.g. 2016/04/19 23:00:00)
      • toCalendar

        public static java.util.Calendar toCalendar​(java.lang.String str,
                                                    java.lang.String format)
        Convert String to Calendar.
        Parameters:
        str - String (e.g. "2016/04/19 23:00:00")
        format - DateTimeFormatter.ofPattern(java.lang.String) (e.g. "uuuu/MM/dd HH:mm:ss")
        Returns:
        Calendar (e.g. 2016/04/19 23:00:00)
      • toYearMonth

        public static java.time.YearMonth toYearMonth​(java.util.Calendar cal)
        Convert Calendar to YearMonth.
        Parameters:
        cal - Calendar (e.g. 2016/04/19 23:00:00)
        Returns:
        YearMonth (e.g. 2016/04)
      • toYearMonth

        public static java.time.YearMonth toYearMonth​(java.lang.String str,
                                                      java.lang.String format)
        Convert String to YearMonth.
        Parameters:
        str - String (e.g. "2016/04")
        format - DateTimeFormatter.ofPattern(java.lang.String) (e.g. "uuuu/MM")
        Returns:
        YearMonth (e.g. 2016/04)
      • toString

        public static java.lang.String toString​(java.time.ZonedDateTime zonedDateTime,
                                                java.lang.String timeZone,
                                                java.lang.String format)
        Convert ZonedDateTime to String.
        Parameters:
        zonedDateTime - ZonedDateTime (e.g. 2016/04/19 23:00:00 +0000)
        timeZone - ZoneId like UTC, JST, ECT, or Asia/Tokyo, Europe/Paris... (e.g. JST)
        format - DateTimeFormatter.ofPattern(java.lang.String) (e.g. "uuuu/MM/dd HH:mm:ss Z")
        Returns:
        String (e.g. "2016/04/20 08:00:00 +0000")
      • toString

        public static java.lang.String toString​(java.time.ZonedDateTime zonedDateTime,
                                                java.lang.String format)
        Convert ZonedDateTime to String.
        Parameters:
        zonedDateTime - ZonedDateTime (e.g. 2016/04/19 23:00:00 +0000)
        format - DateTimeFormatter.ofPattern(java.lang.String) (e.g. "uuuu/MM/dd HH:mm:ss Z")
        Returns:
        String (e.g. "2016/04/19 23:00:00 +0000")
      • toString

        public static java.lang.String toString​(java.time.LocalDateTime localDateTime,
                                                java.lang.String format)
        Convert LocalDateTime to String.
        Parameters:
        localDateTime - LocalDateTime (e.g. 2016/04/19 23:00:00)
        format - DateTimeFormatter.ofPattern(java.lang.String) (e.g. "uuuu/MM/dd HH:mm:ss")
        Returns:
        String (e.g. "2016/04/19 23:00:00")
      • toString

        public static java.lang.String toString​(java.time.LocalDate localDate,
                                                java.lang.String format)
        Convert LocalDate to String.
        Parameters:
        localDate - LocalDate (e.g. 2016/04/19)
        format - DateTimeFormatter.ofPattern(java.lang.String) (e.g. "uuuu/MM/dd HH:mm:ss")
        Returns:
        String (e.g. "2016/04/19 00:00:00")
      • toString

        public static java.lang.String toString​(java.time.LocalTime localTime,
                                                java.lang.String format)
        Convert LocalTime to String.
        Parameters:
        localTime - LocalTime (e.g. 2016/04/19)
        format - DateTimeFormatter.ofPattern(java.lang.String) (e.g. "uuuu/MM/dd HH:mm:ss")
        Returns:
        String (e.g. "2016/04/19 00:00:00")
      • toString

        public static java.lang.String toString​(java.util.Date date,
                                                java.lang.String format)
        Convert Date to String.
        Parameters:
        date - Date (e.g. 2016/04/19 23:00:00)
        format - DateTimeFormatter.ofPattern(java.lang.String) (e.g. "uuuu/MM/dd HH:mm:ss")
        Returns:
        String (e.g. "2016/04/19 23:00:00")
      • toString

        public static java.lang.String toString​(java.util.Calendar cal,
                                                java.lang.String format)
        Convert Calendar to String.
        Parameters:
        cal - Calendar (e.g. 2016/04/19 23:00:00)
        format - DateTimeFormatter.ofPattern(java.lang.String) (e.g. "uuuu/MM/dd HH:mm:ss")
        Returns:
        String (e.g. "2016/04/19 23:00:00")
      • toString

        public static java.lang.String toString​(java.time.YearMonth yearMonth,
                                                java.lang.String format)
        Convert YearMonth to String.
        Parameters:
        yearMonth - YearMonth (e.g. 2016/04)
        format - DateTimeFormatter.ofPattern(java.lang.String) (e.g. "uuuu/MM")
        Returns:
        String (e.g. "2016/04")
      • isIntime

        public static boolean isIntime​(java.util.Date start,
                                       java.util.Date end,
                                       java.util.Date target)
        Check if the date is in the specified period.
        Parameters:
        start - start date
        end - end date
        target - target date
        Returns:
        intime:true, out of time:false