Package io.goobi.viewer.controller
Class DateTools
java.lang.Object
io.goobi.viewer.controller.DateTools
Utility methods for date parsing, etc.
-
Field Summary
Modifier and TypeFieldDescriptionstatic final DateTimeFormatter
ConstantformatterCNDate
static final DateTimeFormatter
ConstantformatterDEDate
static final DateTimeFormatter
ConstantformatterDEDateTime
static final DateTimeFormatter
ConstantformatterDEDateTimeNoSeconds
static final DateTimeFormatter
ConstantformatterUSDate
static final DateTimeFormatter
ConstantformatterENDateTime
static final DateTimeFormatter
ConstantformatterENDateTimeNoSeconds
static final DateTimeFormatter
static final DateTimeFormatter
ConstantformatterISO8601BasicDate
static final DateTimeFormatter
ConstantformatterISO8601BasicDateNoYear
static final DateTimeFormatter
ConstantformatterBasicDateTime
static final DateTimeFormatter
ConstantformatterISO8601Date
static final DateTimeFormatter
ConstantformatterISO8601DateReverse
static final DateTimeFormatter
ConstantformatterISO8601DateTime
static final DateTimeFormatter
ConstantformatterISO8601DateTimeInstant
static final DateTimeFormatter
ConstantformatterISO8601DateTimeMS
static final DateTimeFormatter
ConstantformatterISO8601DateTimeNoSeconds
static final DateTimeFormatter
ConstantformatterISO8601DateTimeWithOffset
static final DateTimeFormatter
ConstantformatterISO8601Full
static final DateTimeFormatter
ConstantformatterISO8601Date
static final DateTimeFormatter
ConstantformatterISO8601YearMonth
static final DateTimeFormatter
ConstantformatterJavaUtilDateToString
static final DateTimeFormatter
ConstantformatterJPDate
static final DateTimeFormatter
static final DateTimeFormatter
-
Method Summary
Modifier and TypeMethodDescriptionstatic LocalDateTime
convertDateToLocalDateTimeViaInstant
(Date dateToConvert) static Date
convertLocalDateTimeToDateViaInstant
(LocalDateTime dateToConvert, boolean utc) static String
format
(LocalDateTime localDateTime, DateTimeFormatter formatter, boolean utc) static String
format
(Date date, DateTimeFormatter formatter, boolean utc) static String
formatDate
(LocalDateTime ldt, Locale locale) Converts the givenLocalDateTime
to a locale-based string format.static String
getLocalDate
(LocalDateTime date, String language) Returns the string representation of the givenDate
based on the given ISO 639-1 language code.static LocalDateTime
getLocalDateTimeFromMillis
(long millis, boolean utc) static Long
getMillisFromLocalDateTime
(LocalDateTime ldt, boolean utc) static LocalDateTime
parseDateFromString
(String dateString) parseDateFromString.static LocalDateTime
parseDateTimeFromString
(String dateString, boolean fromUTC) static LocalDateTime
parseDateTimeFromString
(String dateString, boolean fromUTC, Integer zoneOffset) parseDateTimeFromString.static List<LocalDateTime>
parseMultipleDatesFromString
(String dateString) Converts the given string to a list of Date objects created from the contents of this string (years or whole dates).
-
Field Details
-
FORMATTERISO8601FULL
ConstantformatterISO8601Full
-
FORMATTERISO8601DATETIMEINSTANT
ConstantformatterISO8601DateTimeInstant
-
FORMATTERISO8601DATETIMEWITHOFFSET
ConstantformatterISO8601DateTimeWithOffset
-
FORMATTERISO8601DATE
ConstantformatterISO8601Date
-
FORMATTERISO8601TIME
ConstantformatterISO8601Date
-
FORMATTERISO8601DATEREVERSE
ConstantformatterISO8601DateReverse
-
FORMATTERISO8601YEARMONTH
ConstantformatterISO8601YearMonth
-
FORMATTERISO8601DATETIME
ConstantformatterISO8601DateTime
-
FORMATTERISO8601DATETIMEMS
ConstantformatterISO8601DateTimeMS
-
FORMATTERDEDATE
ConstantformatterDEDate
-
FORMATTERENDATE
ConstantformatterUSDate
-
FORMATTERCNDATE
ConstantformatterCNDate
-
FORMATTERJPDATE
ConstantformatterJPDate
-
FORMATTERISO8601DATETIMENOSECONDS
ConstantformatterISO8601DateTimeNoSeconds
-
FORMATTERDEDATETIME
ConstantformatterDEDateTime
-
FORMATTERENDATETIME
ConstantformatterENDateTime
-
FORMATTERDEDATETIMENOSECONDS
ConstantformatterDEDateTimeNoSeconds
-
FORMATTERENDATETIMENOSECONDS
ConstantformatterENDateTimeNoSeconds
-
FORMATTERISO8601BASICDATENOYEAR
ConstantformatterISO8601BasicDateNoYear
-
FORMATTERISO8601BASICDATE
ConstantformatterISO8601BasicDate
-
FORMATTERISO8601BASICDATETIME
ConstantformatterBasicDateTime
-
FORMATTERJAVAUTILDATETOSTRING
ConstantformatterJavaUtilDateToString
-
FORMATTERYEARONLY
-
FORMATTERMONTHDAYONLY
-
FORMATTERFILENAME
-
-
Method Details
-
parseMultipleDatesFromString
Converts the given string to a list of Date objects created from the contents of this string (years or whole dates). -
getLocalDateTimeFromMillis
- Parameters:
millis
-utc
-- Returns:
LocalDateTime
built from millis
-
getMillisFromLocalDateTime
- Parameters:
ldt
-utc
-- Returns:
Long
built from ldt
-
parseDateTimeFromString
- Parameters:
dateString
-fromUTC
-- Returns:
LocalDateTime
parsed from dateString
-
parseDateTimeFromString
public static LocalDateTime parseDateTimeFromString(String dateString, boolean fromUTC, Integer zoneOffset) parseDateTimeFromString.
- Parameters:
dateString
- aString
object.fromUTC
- a boolean.zoneOffset
-- Returns:
- a
LocalDateTime
object.
-
parseDateFromString
parseDateFromString.
-
convertLocalDateTimeToDateViaInstant
- Parameters:
dateToConvert
-utc
-- Returns:
Date
converted from dateToConvert
-
convertDateToLocalDateTimeViaInstant
- Parameters:
dateToConvert
-- Returns:
LocalDateTime
converted form dateToConvert
-
format
-
format
- Parameters:
localDateTime
-formatter
-utc
-- Returns:
- Formatted
LocalDateTime
asString
-
getLocalDate
Returns the string representation of the givenDate
based on the given ISO 639-1 language code.- Parameters:
date
- LocalDateTime to format.language
- ISO 639-1 (two-character) language code.- Returns:
- a
String
object.
-
formatDate
Converts the givenLocalDateTime
to a locale-based string format. This method is used by the crowdsourcing module.- Parameters:
ldt
- aLocalDateTime
object.locale
- aLocale
object.- Returns:
- a
String
object.
-