Package com.github.toolarium.common.util
Class DateUtil
- java.lang.Object
-
- com.github.toolarium.common.util.DateUtil
-
public final class DateUtil extends java.lang.ObjectDate converter utility.
-
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description java.util.DatecreateDate(int year, int month, int day)Creates a date from the given datajava.util.DatecreateTimeStamp(int year, int month, int day)Creates a date from the given datajava.util.DatecreateTimeStamp(int year, int month, int day, int hour, int min, int sec, int miliSec)Creates a date from the given datastatic DateUtilgetInstance()Get the instancejava.util.DateparseDate(java.lang.String date)Parse a datejava.util.DateparseDate(java.lang.String date, java.lang.String timeSeparator)Parse a datejava.util.DateparseTime(java.lang.String time)Parse the timejava.util.DatetoDate(java.time.LocalDate dateToConvert)Convert toDate.java.util.DatetoDate(java.time.LocalDateTime dateToConvert)Convert toDate.java.lang.StringtoDateString(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.StringtoDateString(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.LocalDatetoLocalDate(java.util.Date dateToConvert)Convert toLocalDate.java.time.LocalDateTimetoLocalDateTime(java.util.Date dateToConvert)Convert toLocalDateTime.java.lang.StringtoTimestampString(java.util.Date date)Converts a given date back into an iso standard: <yyyy-mm-ddTHH24:MI:SS>
-
-
-
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 yearmonth- 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 yearmonth- 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 yearmonth- the month (January starts with 0)day- the day (start with 1)hour- the hour (24h)min- the minutesec- the secondsmiliSec- the milliseconds- Returns:
- the date
-
toLocalDate
public java.time.LocalDate toLocalDate(java.util.Date dateToConvert)
Convert toLocalDate.- Parameters:
dateToConvert- the date to convert- Returns:
- the local date
-
toLocalDateTime
public java.time.LocalDateTime toLocalDateTime(java.util.Date dateToConvert)
Convert toLocalDateTime.- Parameters:
dateToConvert- the date to convert- Returns:
- the local date time
-
toDate
public java.util.Date toDate(java.time.LocalDate dateToConvert)
Convert toDate.- Parameters:
dateToConvert- the date to convert- Returns:
- the date
-
toDate
public java.util.Date toDate(java.time.LocalDateTime dateToConvert)
Convert toDate.- 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:22timeSeparator- 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 objectsep- 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
-
-