Package fr.gouv.vitam.common
Class LocalDateUtil
java.lang.Object
fr.gouv.vitam.common.LocalDateUtil
LocalDateTime utilities
-
Field Summary
Fields -
Method Summary
Modifier and TypeMethodDescriptionstatic longstatic LocalDateTimestatic LocalDateTimefromEpochMilliUTC(long epochMilli) static ClockgetClock()static Datestatic DategetDate(LocalDateTime ldt) static DateTimeFormatterreturn a DateTimeFormatter suitable for filename in the format yyyyMMddHHmmssSSSstatic DateTimeFormatterstatic DateTimeFormatterstatic Stringstatic StringgetFormattedDate(Date date) static StringgetFormattedDateForEsIndexes(LocalDateTime localDateTime) Use to have homogeneous String date format on ES indexesstatic StringgetFormattedDateForMongo(String dateTime) Deprecated.Use getFormattedDateTimeForMongostatic StringgetFormattedDateForMongo(LocalDateTime dateTime) Deprecated.Use getFormattedDateTimeForMongostatic Stringstatic StringgetFormattedDateTimeForMongo(String dateTime) 2016-09-27T12:34:56.123 2016-09-27T00:00:00.000 Use to have homogeneous String date format on databasestatic StringUse to have homogeneous String date format on databasestatic String2024-12-25static StringgetFormattedSimpleDate(Date date) static Instantstatic LocalDatestatic StringgetString(LocalDateTime localDateTime) Deprecated.Use getFormattedDateTimeForMongostatic StringDeprecated.Use getFormattedDateTimeForMongostatic StringgetStringFormatted(LocalDateTime localDateTime) Deprecated.Use getFormattedDateTimeForMongostatic LocalDateTimemax(LocalDateTime localDateTime1, LocalDateTime localDateTime2) static LocalDateTimenow()2024-12-25T12:34:56:123 2024-12-25T12:00:00.000static String2024-12-25T12:34:56:123 2024-12-25T12:00:00.000static LocalDateTimeparse(String dateTimeStr, DateTimeFormatter formatter) static LocalDate2024-12-25static LocalDateTimeParses a mongo formated datestatic voidstatic voidstatic LocalDatetoday()2024-12-25 2024-12-25static String2024-12-25static longtoEpochMilliUTC(LocalDateTime localDateTime) static StringTransform ISO_OFFSET_DATE to ISO_OFFSET_DATE_TIME
-
Field Details
-
SIMPLE_DATE_FORMAT
- See Also:
-
LONG_SECOND_DATE_FORMAT
- See Also:
-
EPOCH
-
-
Method Details
-
getString
Deprecated.Use getFormattedDateTimeForMongoFormats date/time in ISO_DATE_TIME. Seconds / milliseconds are truncated when 0 -
getStringFormatted
Deprecated.Use getFormattedDateTimeForMongoFormats date/time in ISO_DATE_TIME. Seconds / milliseconds are truncated when 0 -
getString
Deprecated.Use getFormattedDateTimeForMongoFormats date/time in ISO_DATE_TIME. Seconds / milliseconds are truncated when 0 -
now
2024-12-25T12:34:56:123 2024-12-25T12:00:00.000- Returns:
- the LocalDateTime now in UTC
-
today
2024-12-25 2024-12-25- Returns:
- the LocalDate today in UTC
-
nowFormatted
2024-12-25T12:34:56:123 2024-12-25T12:00:00.000 -
todayFormatted
2024-12-25 -
getDate
- Parameters:
date- in format String to transform- Returns:
- the corresponding Date from date string
- Throws:
IllegalArgumentException- date null or emptyParseException
-
fromDate
- Parameters:
date- in format Date to transform- Returns:
- the corresponding LocalDateTime in UTC
-
getDate
- Parameters:
ldt- in format LocalDateTime to transform- Returns:
- the corresponding date
-
getFormattedDate
- Parameters:
date- date- Returns:
- formatted date
-
getFormattedDate
- Parameters:
date- date- Returns:
- formatted date
-
getFormattedSimpleDate
- Parameters:
date- date- Returns:
- formatted date
-
getFormattedSimpleDate
2024-12-25 -
getLocalDateFromSimpleFormattedDate
- Parameters:
date- formatted date- Returns:
- the corresponding LocalDate
-
getFormattedDateTimeForMongo
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
Use to have homogeneous String date format on database- Parameters:
date- the date to format for database- Returns:
- the formatted date for database
-
getFormattedDateForMongo
Deprecated.Use getFormattedDateTimeForMongo -
getFormattedDateOnlyForMongo
-
getFormattedDateForMongo
Deprecated.Use getFormattedDateTimeForMongo -
transformIsoOffsetDateToIsoOffsetDateTime
Transform ISO_OFFSET_DATE to ISO_OFFSET_DATE_TIME- Parameters:
date- the date to format for elastic- Returns:
- the formatted date for elastic
-
parseMongoFormattedDate
Parses a mongo formated date- Parameters:
str- formatted date in database- Returns:
- the parsed local date time
-
parseDate
2024-12-25 -
getFormattedDateForEsIndexes
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
return a DateTimeFormatter suitable for filename in the format yyyyMMddHHmmssSSS -
getDateTimeFormatterForStorageTraceabilityFileNames
-
getDateTimeFormatterForStorageLogFileNames
-
currentTimeMillis
public static long currentTimeMillis() -
max
-
parse
-
fromEpochMilliUTC
-
toEpochMilliUTC
-
getInstant
-
getClock
-
setClock
-
resetClock
public static void resetClock()
-