Class DateTools

java.lang.Object
io.goobi.viewer.controller.DateTools

public final class DateTools extends Object
Utility methods for date parsing, etc.
  • Field Details

    • FORMATTERISO8601FULL

      public static final DateTimeFormatter FORMATTERISO8601FULL
      Constant formatterISO8601Full
    • FORMATTERISO8601DATETIMEINSTANT

      public static final DateTimeFormatter FORMATTERISO8601DATETIMEINSTANT
      Constant formatterISO8601DateTimeInstant
    • FORMATTERISO8601DATETIMEWITHOFFSET

      public static final DateTimeFormatter FORMATTERISO8601DATETIMEWITHOFFSET
      Constant formatterISO8601DateTimeWithOffset
    • FORMATTERISO8601DATE

      public static final DateTimeFormatter FORMATTERISO8601DATE
      Constant formatterISO8601Date
    • FORMATTERISO8601TIME

      public static final DateTimeFormatter FORMATTERISO8601TIME
      Constant formatterISO8601Date
    • FORMATTERISO8601DATEREVERSE

      public static final DateTimeFormatter FORMATTERISO8601DATEREVERSE
      Constant formatterISO8601DateReverse
    • FORMATTERISO8601YEARMONTH

      public static final DateTimeFormatter FORMATTERISO8601YEARMONTH
      Constant formatterISO8601YearMonth
    • FORMATTERISO8601DATETIME

      public static final DateTimeFormatter FORMATTERISO8601DATETIME
      Constant formatterISO8601DateTime
    • FORMATTERISO8601DATETIMEMS

      public static final DateTimeFormatter FORMATTERISO8601DATETIMEMS
      Constant formatterISO8601DateTimeMS
    • FORMATTERDEDATE

      public static final DateTimeFormatter FORMATTERDEDATE
      Constant formatterDEDate
    • FORMATTERENDATE

      public static final DateTimeFormatter FORMATTERENDATE
      Constant formatterUSDate
    • FORMATTERCNDATE

      public static final DateTimeFormatter FORMATTERCNDATE
      Constant formatterCNDate
    • FORMATTERJPDATE

      public static final DateTimeFormatter FORMATTERJPDATE
      Constant formatterJPDate
    • FORMATTERISO8601DATETIMENOSECONDS

      public static final DateTimeFormatter FORMATTERISO8601DATETIMENOSECONDS
      Constant formatterISO8601DateTimeNoSeconds
    • FORMATTERDEDATETIME

      public static final DateTimeFormatter FORMATTERDEDATETIME
      Constant formatterDEDateTime
    • FORMATTERENDATETIME

      public static final DateTimeFormatter FORMATTERENDATETIME
      Constant formatterENDateTime
    • FORMATTERDEDATETIMENOSECONDS

      public static final DateTimeFormatter FORMATTERDEDATETIMENOSECONDS
      Constant formatterDEDateTimeNoSeconds
    • FORMATTERENDATETIMENOSECONDS

      public static final DateTimeFormatter FORMATTERENDATETIMENOSECONDS
      Constant formatterENDateTimeNoSeconds
    • FORMATTERISO8601BASICDATENOYEAR

      public static final DateTimeFormatter FORMATTERISO8601BASICDATENOYEAR
      Constant formatterISO8601BasicDateNoYear
    • FORMATTERISO8601BASICDATE

      public static final DateTimeFormatter FORMATTERISO8601BASICDATE
      Constant formatterISO8601BasicDate
    • FORMATTERISO8601BASICDATETIME

      public static final DateTimeFormatter FORMATTERISO8601BASICDATETIME
      Constant formatterBasicDateTime
    • FORMATTERJAVAUTILDATETOSTRING

      public static final DateTimeFormatter FORMATTERJAVAUTILDATETOSTRING
      Constant formatterJavaUtilDateToString
    • FORMATTERYEARONLY

      public static final DateTimeFormatter FORMATTERYEARONLY
    • FORMATTERMONTHDAYONLY

      public static final DateTimeFormatter FORMATTERMONTHDAYONLY
    • FORMATTERFILENAME

      public static final DateTimeFormatter FORMATTERFILENAME
  • Method Details

    • parseMultipleDatesFromString

      public 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).
      Parameters:
      dateString - a String object.
      Returns:
      a List object.
    • getLocalDateTimeFromMillis

      public static LocalDateTime getLocalDateTimeFromMillis(long millis, boolean utc)
      Parameters:
      millis -
      utc -
      Returns:
      LocalDateTime built from millis
    • getMillisFromLocalDateTime

      public static Long getMillisFromLocalDateTime(LocalDateTime ldt, boolean utc)
      Parameters:
      ldt -
      utc -
      Returns:
      Long built from ldt
    • parseDateTimeFromString

      public static LocalDateTime parseDateTimeFromString(String dateString, boolean fromUTC)
      Parameters:
      dateString -
      fromUTC -
      Returns:
      LocalDateTime parsed from dateString
    • parseDateTimeFromString

      public static LocalDateTime parseDateTimeFromString(String dateString, boolean fromUTC, Integer zoneOffset)

      parseDateTimeFromString.

      Parameters:
      dateString - a String object.
      fromUTC - a boolean.
      zoneOffset -
      Returns:
      a LocalDateTime object.
    • parseDateFromString

      public static LocalDateTime parseDateFromString(String dateString)

      parseDateFromString.

      Parameters:
      dateString - a String object.
      Returns:
      a Date object.
    • convertLocalDateTimeToDateViaInstant

      public static Date convertLocalDateTimeToDateViaInstant(LocalDateTime dateToConvert, boolean utc)
      Parameters:
      dateToConvert -
      utc -
      Returns:
      Date converted from dateToConvert
    • convertDateToLocalDateTimeViaInstant

      public static LocalDateTime convertDateToLocalDateTimeViaInstant(Date dateToConvert)
      Parameters:
      dateToConvert -
      Returns:
      LocalDateTime converted form dateToConvert
    • format

      public static String format(Date date, DateTimeFormatter formatter, boolean utc)
      Parameters:
      date - java.util.Date
      formatter -
      utc -
      Returns:
      Formatted Date as String
    • format

      public static String format(LocalDateTime localDateTime, DateTimeFormatter formatter, boolean utc)
      Parameters:
      localDateTime -
      formatter -
      utc -
      Returns:
      Formatted LocalDateTime as String
    • getLocalDate

      public static String getLocalDate(LocalDateTime date, String language)
      Returns the string representation of the given Date 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

      public static String formatDate(LocalDateTime ldt, Locale locale)
      Converts the given LocalDateTime to a locale-based string format. This method is used by the crowdsourcing module.
      Parameters:
      ldt - a LocalDateTime object.
      locale - a Locale object.
      Returns:
      a String object.