Class DateUtil

java.lang.Object
com.github.toolarium.common.util.DateUtil

public final class DateUtil extends Object
Date converter utility.
  • Method Details

    • getInstance

      public static DateUtil getInstance()
      Get the instance
      Returns:
      the instance
    • createDate

      public Date createDate(int year, int month, int day)
      Creates a date from the given data
      Parameters:
      year - the year
      month - the month (January starts with 0)
      day - the day (start with 1)
      Returns:
      the date
    • createTimeStamp

      public Date createTimeStamp(int year, int month, int day)
      Creates a date from the given data
      Parameters:
      year - the year
      month - the month January starts with 0)
      day - the day (start with 1)
      Returns:
      the date
    • createTimeStamp

      public Date createTimeStamp(int year, int month, int day, int hour, int min, int sec, int miliSec)
      Creates a date from the given data
      Parameters:
      year - the year
      month - the month (January starts with 0)
      day - the day (start with 1)
      hour - the hour (24h)
      min - the minute
      sec - the seconds
      miliSec - the milliseconds
      Returns:
      the date
    • toLocalDate

      public LocalDate toLocalDate(Date dateToConvert)
      Convert to LocalDate.
      Parameters:
      dateToConvert - the date to convert
      Returns:
      the local date
    • toLocalDateTime

      public LocalDateTime toLocalDateTime(Date dateToConvert)
      Convert to LocalDateTime.
      Parameters:
      dateToConvert - the date to convert
      Returns:
      the local date time
    • toDate

      public Date toDate(LocalDate dateToConvert)
      Convert to Date.
      Parameters:
      dateToConvert - the date to convert
      Returns:
      the date
    • toDate

      public Date toDate(LocalDateTime dateToConvert)
      Convert to Date.
      Parameters:
      dateToConvert - the date to convert
      Returns:
      the date
    • parseTime

      public Date parseTime(String time)
      Parse the time
      Parameters:
      time - the time to parse like: 11:22
      Returns:
      the parsed time as date
      Throws:
      IllegalArgumentException - In case of invalid time format
    • parseDate

      public Date parseDate(String date)
      Parse a date
      Parameters:
      date - the date to parse like: 10.02.2004, 10.2.04@11:22
      Returns:
      the date
      Throws:
      IllegalArgumentException - In case of invalid dateformat
    • parseDate

      public Date parseDate(String date, String timeSeparator)
      Parse a date
      Parameters:
      date - the date to parse like: 10.02.2004, 10.2.04@11:22
      timeSeparator - the time separator
      Returns:
      the date
      Throws:
      IllegalArgumentException - In case of invalid dateformat
    • toDateString

      public String toDateString(Date date)
      Converts a given date back into toolarium-date-notation and returns a well formed string of the following format: <dd.mm.yyyy@HH24:MI:SS>
      Parameters:
      date - the date object
      Returns:
      date as string
    • toDateString

      public String toDateString(Date date, String sep)
      Converts a given date back into toolarium-date-notation and returns a well formed string of the following format: <dd.mm.yyyy@HH24:MI:SS>
      Parameters:
      date - the date object
      sep - the separator
      Returns:
      date as string
    • toDateString

      public String toDateString(Instant instant)
      Converts a given date back into toolarium-date-notation and returns a well formed string of the following format: <dd.mm.yyyy@HH24:MI:SS>
      Parameters:
      instant - the instant object
      Returns:
      date as string
    • toDateString

      public String toDateString(Instant instant, String sep)
      Converts a given date back into toolarium-date-notation and returns a well formed string of the following format: <dd.mm.yyyy@HH24:MI:SS>
      Parameters:
      instant - the instant object
      sep - the separator
      Returns:
      date as string
    • toTimestampString

      public String toTimestampString(Date date)
      Converts a given date back into an iso standard: <yyyy-mm-ddTHH24:MI:SS>
      Parameters:
      date - the date object
      Returns:
      date as string