Class DateUtil


  • public final class DateUtil
    extends java.lang.Object
    Date converter utility.
    • Method Summary

      All Methods Static Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      java.util.Date createDate​(int year, int month, int day)
      Creates a date from the given data
      java.util.Date createTimeStamp​(int year, int month, int day)
      Creates a date from the given data
      java.util.Date createTimeStamp​(int year, int month, int day, int hour, int min, int sec, int miliSec)
      Creates a date from the given data
      static DateUtil getInstance()
      Get the instance
      java.util.Date parseDate​(java.lang.String date)
      Parse a date
      java.util.Date parseDate​(java.lang.String date, java.lang.String timeSeparator)
      Parse a date
      java.util.Date parseTime​(java.lang.String time)
      Parse the time
      java.util.Date toDate​(java.time.LocalDate dateToConvert)
      Convert to Date.
      java.util.Date toDate​(java.time.LocalDateTime dateToConvert)
      Convert to Date.
      java.lang.String toDateString​(java.util.Date date)
      Converts a given date back into jptools-date-notation and returns a well formed string of the following format: <dd.mm.yyyy@HH24:MI:SS>
      java.lang.String toDateString​(java.util.Date date, java.lang.String sep)
      Converts a given date back into jptools-date-notation and returns a well formed string of the following format: <dd.mm.yyyy@HH24:MI:SS>
      java.time.LocalDate toLocalDate​(java.util.Date dateToConvert)
      Convert to LocalDate.
      java.time.LocalDateTime toLocalDateTime​(java.util.Date dateToConvert)
      Convert to LocalDateTime.
      java.lang.String toTimestampString​(java.util.Date date)
      Converts a given date back into an iso standard: <yyyy-mm-ddTHH24:MI:SS>
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Method Detail

      • getInstance

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

        public java.util.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 java.util.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 java.util.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 java.time.LocalDate toLocalDate​(java.util.Date dateToConvert)
        Convert to LocalDate.
        Parameters:
        dateToConvert - the date to convert
        Returns:
        the local date
      • toLocalDateTime

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

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

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

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

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

        public java.util.Date parseDate​(java.lang.String date,
                                        java.lang.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:
        java.lang.IllegalArgumentException - In case of invalid dateformat
      • toDateString

        public java.lang.String toDateString​(java.util.Date date)
        Converts a given date back into jptools-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 java.lang.String toDateString​(java.util.Date date,
                                             java.lang.String sep)
        Converts a given date back into jptools-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
      • toTimestampString

        public java.lang.String toTimestampString​(java.util.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