Class DateTimeApiUtil

java.lang.Object
jp.ecuacion.lib.core.util.DateTimeApiUtil

public class DateTimeApiUtil extends Object
Provides Utility methods related to dateTime Api.
  • Method Details

    • getLocalDateTimeDisplayString

      @Nonnull public static String getLocalDateTimeDisplayString(@RequireNonnull LocalDateTime localDateTime)
      Returns user-friendly LocalDateTime format string : yyyy-MM-dd HH:mm:ss.
      Parameters:
      localDateTime - localDateTime
      Returns:
      localDateTime string: yyyy-MM-dd HH:mm:ss
    • getLocalDateTimeDisplayString

      @Nonnull public static String getLocalDateTimeDisplayString(@RequireNonnull OffsetDateTime dateTime, @Nullable ZoneId zoneId)
      Returns user-friendly LocalDateTime format string : yyyy-MM-dd HH:mm:ss.
      Parameters:
      dateTime - offsetDateTime
      zoneId - zoneId, may be null which is treated as ZoneId.systemDefault(). ZoneOffset is also available, which extends ZoneId.
      Returns:
      localDateTime string: yyyy-MM-dd HH:mm:ss
    • getTimestampStringForFilename

      @Nonnull public static String getTimestampStringForFilename(LocalDateTime dateTime)
      Returns filename LocalDateTime format string : yyyy-MM-dd-HH-mm-ss-SSSSSS.
      Parameters:
      dateTime - offsetDateTime
      Returns:
      localDateTime string
    • getOffsetDateTimeDisplayString

      @Nonnull public static String getOffsetDateTimeDisplayString(@RequireNonnull OffsetDateTime offsetDateTime, @Nullable ZoneId zoneId)
      Returns user-friendly OffsetDateTime format string : yyyy-MM-dd HH:mm:ss +HH:mm.
      Parameters:
      offsetDateTime - offsetDateTime
      zoneId - zoneId, may be null which is treated as ZoneId.systemDefault(). ZoneOffset is also available, which extends ZoneId.
      Returns:
      offsetDateTime string: yyyy-MM-dd HH:mm:ss +HH:mm
    • getLocalDateTime

      @Nonnull public static LocalDateTime getLocalDateTime(@RequireNonnull String dateTimeString)
      Returns a LocalDateTime instance from date-time string.

      year must be 4 digits and other elements must be 2 digits. (not like "1", but like "01")
      Valid formats are as follows.

      • 2001-01-01 01:01:01 (The separator of year, month and day of month is dash)
      • 2001/01/01 01:01:01 (The separator of year, month and day of month is slash)
      • 2001-01-01T01:01:01 (The separator of the date and the time is "T")
      • 2001-01-01 01:01:01.123 (Smaller seconds than 1 are added)
      Parameters:
      dateTimeString - dateTimeString
      Returns:
      LocalDateTime
    • getOffsetDateTime

      @Nonnull public static OffsetDateTime getOffsetDateTime(@RequireNonnull String dateTimeString)
      Returns a OffsetDateTime instance from date-time string.

      year must be 4 digits and other elements must be 2 digits. (not like "1", but like "01")
      Valid formats are as follows. (The validation of localDateTime-part is exactly the same as getLocalDateTime(String dateTimeString)

      • (localDateTime-part)+09:00
      • (localDateTime-part) +09:00
      Parameters:
      dateTimeString - dateTimeString
      Returns:
      OffsetDateTime