public class DateUtils extends Object
| Constructor and Description |
|---|
DateUtils() |
| Modifier and Type | Method and Description |
|---|---|
static String |
dateToString(Calendar date,
String pattern)
Parse a string from the parameter pattern
|
static String |
dateToString(Date date,
String pattern)
Format a date from the parameter pattern
|
static int |
getAge(Date date)
Return a age (based on year)
|
static int |
getDay(Date date)
Return the day of a date.
|
static Date |
getFirstDayInMonth(int month,
int year)
Return the first day in month.
|
static Date |
getFirstDayInYear(int year)
Return the first day in year.
|
static Date |
getLastDayInMonth(int month,
int year)
Return the first day in month.
|
static Date |
getLastDayInYear(int year)
Return the last day in year.
|
static int |
getMonth(Date date)
Return the month of a date.
|
static int |
getYear(Date date)
Return the year of a date.
|
static Date |
removeTime(Date date)
Get Date with only day, month and year (removing hour, minute, second and
milisecond)
|
static Calendar |
stringToCalendar(String dateString,
String pattern)
Parse a string with the parameter pattern
|
static Date |
stringToDate(String dateString,
String pattern)
Parse a string with the parameter pattern
|
public static Date removeTime(Date date)
date - public static int getAge(Date date)
date - public static Date getFirstDayInMonth(int month, int year)
month - year - public static Date getLastDayInMonth(int month, int year)
month - year - public static Date getFirstDayInYear(int year)
year - public static Date getLastDayInYear(int year)
year - public static int getYear(Date date)
date - public static int getMonth(Date date)
date - public static int getDay(Date date)
date - public static String dateToString(Date date, String pattern)
date - pattern - Date pattern. Example: dd/MM/yyyypublic static String dateToString(Calendar date, String pattern)
date - pattern - Date pattern. Example: dd/MM/yyyypublic static Date stringToDate(String dateString, String pattern) throws ParseException
dateString - pattern - Date pattern. Example: dd/MM/yyyyParseExceptionpublic static Calendar stringToCalendar(String dateString, String pattern) throws ParseException
dateString - pattern - Date pattern. Example: dd/MM/yyyyParseExceptionCopyright © 2015. All rights reserved.