Package fr.gouv.vitam.common
Class LocalDateUtil
java.lang.Object
fr.gouv.vitam.common.LocalDateUtil
LocalDateTime utilities
-
Field Summary
-
Method Summary
Modifier and TypeMethodDescriptionstatic long
static LocalDateTime
static LocalDateTime
fromEpochMilliUTC
(long epochMilli) static Clock
getClock()
static Date
static Date
getDate
(LocalDateTime ldt) static DateTimeFormatter
return a DateTimeFormatter suitable for filename in the format yyyyMMddHHmmssSSSstatic DateTimeFormatter
static DateTimeFormatter
static String
static String
getFormattedDate
(Date date) static String
getFormattedDateForEsIndexes
(LocalDateTime localDateTime) Use to have homogeneous String date format on ES indexesstatic String
getFormattedDateForMongo
(String dateTime) Deprecated.Use getFormattedDateTimeForMongostatic String
getFormattedDateForMongo
(LocalDateTime dateTime) Deprecated.Use getFormattedDateTimeForMongostatic String
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 databasestatic String
Use to have homogeneous String date format on databasestatic String
2024-12-25static String
getFormattedSimpleDate
(Date date) static Instant
static LocalDate
static String
getString
(LocalDateTime localDateTime) Deprecated.Use getFormattedDateTimeForMongostatic String
Deprecated.Use getFormattedDateTimeForMongostatic String
getStringFormatted
(LocalDateTime localDateTime) Deprecated.Use getFormattedDateTimeForMongostatic LocalDateTime
max
(LocalDateTime localDateTime1, LocalDateTime localDateTime2) static LocalDateTime
now()
2024-12-25T12:34:56:123 2024-12-25T12:00:00.000static String
2024-12-25T12:34:56:123 2024-12-25T12:00:00.000static LocalDateTime
parse
(String dateTimeStr, DateTimeFormatter formatter) static LocalDate
2024-12-25static LocalDateTime
Parses a mongo formated datestatic void
static void
static LocalDate
today()
2024-12-25 2024-12-25static String
2024-12-25static long
toEpochMilliUTC
(LocalDateTime localDateTime) static String
Transform 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()
-