public class Dates extends Object
| Modifier and Type | Method and Description |
|---|---|
static Date |
createDate(int year,
Month month,
int day)
Creates date according the Gregorian calendar input.
|
static Date |
createTime(int year,
Month month,
int day,
int hour,
int minute,
int second)
Creates time according the Gregorian calendar input.
|
static Date |
createTime(int year,
Month month,
int day,
int hour,
int minute,
int second,
int millisecond)
Creates time according the Gregorian calendar input.
|
static String |
format(Date date,
String pattern)
Formats date into string.
|
static Date |
fromToday(int numDays)
Returns the date which is shifted for a particular number of days from
today.
|
static int |
getDayOfMonth(Date date)
Returns day of month.
|
static DayOfWeek |
getDayOfWeek(Date date)
Returns day of week.
|
static int |
getDayOfYear(Date date)
Takes the time in a given date and returns how many days past from the beginning of the year.
|
static int |
getDifferenceInDays(Date first,
Date second)
Returns the difference in days between two dates.
|
static int |
getHourOfDay(Date date)
Takes the time in a given date and returns how many hours past from the
specified day from 0 : 0 : 0.
|
static int |
getMinuteOfDay(Date date)
Takes the time in a given date and returns how many minutes past from the
specified day from 0 : 0 : 0.
|
static Month |
getMonth(Date date)
Returns month.
|
static int |
getYear(Date date)
Returns year.
|
static Date |
now()
Returns the current timestamp.
|
static Date |
parse(String date,
String... patterns)
Parses date.
|
static boolean |
safeEqualsToSeconds(Date date1,
Date date2)
Null safe equals method which ignores anything less than seconds.
|
static Date |
today()
Returns todays date.
|
static Date |
tomorrow()
Returns the tomorrows date.
|
static Date |
yesterday()
Returns the yesterdays date.
|
public static Date now()
public static Date today()
public static Date yesterday()
public static Date tomorrow()
public static Date fromToday(int numDays)
numDays - the number of days to shiftpublic static Date createDate(int year, Month month, int day)
year - yearmonth - monthday - day of the month (1-31, range depends on the month and year)public static Date createTime(int year, Month month, int day, int hour, int minute, int second)
year - yearmonth - monthday - day of the month (1-31, range depends on the month and year)hour - hour (0 - 23)minute - minute (0 - 59)second - second (0 - 59)public static Date createTime(int year, Month month, int day, int hour, int minute, int second, int millisecond)
year - yearmonth - monthday - day of the month (1-31, range depends on the month and year)hour - hour (0 - 23)minute - minute (0 - 59)second - second (0 - 59)millisecond - millisecond (0-999)public static int getMinuteOfDay(Date date)
date - input datepublic static int getHourOfDay(Date date)
date - input datepublic static int getDayOfYear(Date date)
date - input datepublic static int getYear(Date date)
date - input datepublic static Month getMonth(Date date)
date - input datepublic static int getDayOfMonth(Date date)
date - input datepublic static DayOfWeek getDayOfWeek(Date date)
date - input datepublic static int getDifferenceInDays(Date first, Date second)
first - first datesecond - second datepublic static String format(Date date, String pattern)
date - date which will be formattedpattern - pattern which will be usedpublic static Date parse(String date, String... patterns)
date - date string which will be parsedpatterns - patterns which will be used, result is returned from the first pattern which can parse the stringpublic static boolean safeEqualsToSeconds(Date date1, Date date2)
date1 - first datedate2 - second dateCopyright © 2016. All rights reserved.