public class DateUtils extends Object
Modifier and Type | Field and Description |
---|---|
static long |
MILLIS_IN_DAY |
Modifier and Type | Method and Description |
---|---|
static Date |
addDate(Date date,
int years,
int months,
int days)
Calculates a date relative to the supplied date.
|
static long |
compareDates(Date date1,
Date date2) |
static boolean |
compareEqual(Date date1,
Date date2) |
static String |
formatDate(Date date,
Locale locale) |
static String |
formatDate(LocalDate localDate,
Locale locale) |
static String |
formatDate(LocalDateTime localDateTime,
Locale locale) |
static String |
formatDateTime(LocalDateTime localDateTime,
Locale locale,
boolean withSeconds) |
static String |
formatDayOfWeek(Date date,
Locale locale,
boolean longFormat) |
static String |
formatMonth(Date date,
Locale locale,
boolean longFormat) |
static String |
formatMonth(int month,
Locale locale,
boolean longFormat) |
static String |
formatTime(Date date,
Locale locale,
boolean withSeconds) |
static String |
formatYear(Date date,
Locale locale) |
static Date |
getDate(int year,
int month,
int day) |
static Date |
getDateNow()
Returns the current date without time
|
static Date |
getDateOnly(Date date) |
static Date |
getDateTime(int year,
int month,
int day,
int hours,
int minutes,
int seconds) |
static Date |
getDateTime(int year,
int month,
int day,
int hours,
int minutes,
int seconds,
int millis) |
static DateTimeFormatter |
getLocalDateFormatter(Locale locale) |
static DateTimeFormatter |
getLocalDateTimeFormatter(Locale locale,
boolean withSeconds) |
static Date |
getTimeNow()
Returns the current date and time
|
static Date |
getTimeOnly(Date date) |
static int |
getWeekOfYear(Date date,
Locale locale) |
static Date |
parseDate(String sDate,
Locale locale) |
static LocalDate |
parseLocalDate(String date) |
static LocalDate |
parseLocalDate(String date,
DateTimeFormatter formatter) |
static LocalDateTime |
parseLocalDateTime(String date) |
static LocalDateTime |
parseLocalDateTime(String date,
DateTimeFormatter formatter) |
static Date |
setDate(Date date,
int year,
int month,
int day) |
static Date |
setTime(Date date,
int hours,
int minutes,
int seconds,
int millis) |
static Date |
toDate(LocalDate localDate) |
static Date |
toDate(LocalDateTime localDateTime) |
static LocalDate |
toLocalDate(Date date) |
static LocalDate |
toLocalDate(Date date) |
static LocalDate |
toLocalDate(Timestamp timestamp) |
static LocalDateTime |
toLocalDateTime(Date date) |
static LocalDateTime |
toLocalDateTime(Date date) |
static LocalDateTime |
toLocalDateTime(Timestamp timestamp) |
public static final long MILLIS_IN_DAY
public static Date getDateNow()
public static Date getTimeNow()
public static Date addDate(Date date, int years, int months, int days)
date
- date to calculate fromyears
- number of years to add or subtract from the supplied datemonths
- number of months to add or subtract from the supplied datedays
- number of days to add or subtract from the supplied datepublic static Date getDate(int year, int month, int day)
public static Date getDateTime(int year, int month, int day, int hours, int minutes, int seconds, int millis)
public static Date getDateTime(int year, int month, int day, int hours, int minutes, int seconds)
public static LocalDateTime toLocalDateTime(Date date)
public static LocalDateTime toLocalDateTime(Timestamp timestamp)
public static LocalDateTime toLocalDateTime(Date date)
public static Date toDate(LocalDateTime localDateTime)
public static LocalDate parseLocalDate(String date, DateTimeFormatter formatter)
public static LocalDateTime parseLocalDateTime(String date)
public static LocalDateTime parseLocalDateTime(String date, DateTimeFormatter formatter)
public static DateTimeFormatter getLocalDateFormatter(Locale locale)
public static DateTimeFormatter getLocalDateTimeFormatter(Locale locale, boolean withSeconds)
public static String formatDate(LocalDateTime localDateTime, Locale locale)
public static String formatDateTime(LocalDateTime localDateTime, Locale locale, boolean withSeconds)
Copyright © 2008–2023 Apache Software Foundation. All rights reserved.