Class LocalDateUtil

java.lang.Object
fr.gouv.vitam.common.LocalDateUtil

public final class LocalDateUtil extends Object
LocalDateTime utilities
  • Field Details

  • Method Details

    • getString

      public static String getString(LocalDateTime localDateTime)
      Deprecated.
      Use getFormattedDateTimeForMongo
      Formats date/time in ISO_DATE_TIME. Seconds / milliseconds are truncated when 0
    • getStringFormatted

      public static String getStringFormatted(LocalDateTime localDateTime)
      Deprecated.
      Use getFormattedDateTimeForMongo
      Formats date/time in ISO_DATE_TIME. Seconds / milliseconds are truncated when 0
    • getString

      public static String getString(Date date)
      Deprecated.
      Use getFormattedDateTimeForMongo
      Formats date/time in ISO_DATE_TIME. Seconds / milliseconds are truncated when 0
    • now

      public static LocalDateTime now()
      2024-12-25T12:34:56:123 2024-12-25T12:00:00.000
      Returns:
      the LocalDateTime now in UTC
    • today

      public static LocalDate today()
      2024-12-25 2024-12-25
      Returns:
      the LocalDate today in UTC
    • nowFormatted

      public static String nowFormatted()
      2024-12-25T12:34:56:123 2024-12-25T12:00:00.000
    • todayFormatted

      public static String todayFormatted()
      2024-12-25
    • getDate

      public static Date getDate(String date) throws ParseException
      Parameters:
      date - in format String to transform
      Returns:
      the corresponding Date from date string
      Throws:
      IllegalArgumentException - date null or empty
      ParseException
    • fromDate

      public static LocalDateTime fromDate(Date date)
      Parameters:
      date - in format Date to transform
      Returns:
      the corresponding LocalDateTime in UTC
    • getDate

      public static Date getDate(LocalDateTime ldt)
      Parameters:
      ldt - in format LocalDateTime to transform
      Returns:
      the corresponding date
    • getFormattedDate

      public static String getFormattedDate(Date date)
      Parameters:
      date - date
      Returns:
      formatted date
    • getFormattedDate

      public static String getFormattedDate(LocalDateTime date)
      Parameters:
      date - date
      Returns:
      formatted date
    • getFormattedSimpleDate

      public static String getFormattedSimpleDate(Date date)
      Parameters:
      date - date
      Returns:
      formatted date
    • getFormattedSimpleDate

      public static String getFormattedSimpleDate(LocalDate date)
      2024-12-25
    • getLocalDateFromSimpleFormattedDate

      public static LocalDate getLocalDateFromSimpleFormattedDate(String date)
      Parameters:
      date - formatted date
      Returns:
      the corresponding LocalDate
    • getFormattedDateTimeForMongo

      public static String getFormattedDateTimeForMongo(String dateTime)
      2016-09-27T12:34:56.123 2016-09-27T00:00:00.000 Use to have homogeneous String date format on database
      Parameters:
      dateTime - the date to format for database
      Returns:
      the formatted date for database
      Throws:
      DateTimeParseException - thrown when cannot parse String date (not ISO_LOCAL_DATE_TIME, not ZONED_DATE_TIME_FORMAT and not ISO_DATE date format)
    • getFormattedDateTimeForMongo

      public static String getFormattedDateTimeForMongo(LocalDateTime date)
      Use to have homogeneous String date format on database
      Parameters:
      date - the date to format for database
      Returns:
      the formatted date for database
    • getFormattedDateForMongo

      public static String getFormattedDateForMongo(String dateTime)
      Deprecated.
      Use getFormattedDateTimeForMongo
    • getFormattedDateOnlyForMongo

      public static String getFormattedDateOnlyForMongo(String date)
    • getFormattedDateForMongo

      public static String getFormattedDateForMongo(LocalDateTime dateTime)
      Deprecated.
      Use getFormattedDateTimeForMongo
    • transformIsoOffsetDateToIsoOffsetDateTime

      public static String transformIsoOffsetDateToIsoOffsetDateTime(String date)
      Transform ISO_OFFSET_DATE to ISO_OFFSET_DATE_TIME
      Parameters:
      date - the date to format for elastic
      Returns:
      the formatted date for elastic
    • parseMongoFormattedDate

      public static LocalDateTime parseMongoFormattedDate(String str)
      Parses a mongo formated date
      Parameters:
      str - formatted date in database
      Returns:
      the parsed local date time
    • parseDate

      public static LocalDate parseDate(String endDateStr)
      2024-12-25
    • getFormattedDateForEsIndexes

      public static String getFormattedDateForEsIndexes(LocalDateTime localDateTime)
      Use to have homogeneous String date format on ES indexes
      Parameters:
      localDateTime - the date to format for database
      Returns:
      the formatted date for database
    • getDateTimeFormatterForFileNames

      public static DateTimeFormatter getDateTimeFormatterForFileNames()
      return a DateTimeFormatter suitable for filename in the format yyyyMMddHHmmssSSS
    • getDateTimeFormatterForStorageTraceabilityFileNames

      public static DateTimeFormatter getDateTimeFormatterForStorageTraceabilityFileNames()
    • getDateTimeFormatterForStorageLogFileNames

      public static DateTimeFormatter getDateTimeFormatterForStorageLogFileNames()
    • currentTimeMillis

      public static long currentTimeMillis()
    • max

      public static LocalDateTime max(LocalDateTime localDateTime1, LocalDateTime localDateTime2)
    • parse

      public static LocalDateTime parse(String dateTimeStr, DateTimeFormatter formatter)
    • fromEpochMilliUTC

      public static LocalDateTime fromEpochMilliUTC(long epochMilli)
    • toEpochMilliUTC

      public static long toEpochMilliUTC(LocalDateTime localDateTime)
    • getInstant

      public static Instant getInstant()
    • getClock

      public static Clock getClock()
    • setClock

      public static void setClock(Clock clock)
    • resetClock

      public static void resetClock()