public class DateUtils extends Object
| Modifier and Type | Field and Description |
|---|---|
static String |
DATE_FORMAT_10 |
static String |
DATE_FORMAT_14 |
static String |
DATE_FORMAT_16 |
static String |
DATE_FORMAT_16_FORWARD_SLASH |
static String |
DATE_FORMAT_17 |
static String |
DATE_FORMAT_19 |
static String |
DATE_FORMAT_19_FORWARD_SLASH |
static long |
DAY_MILLISECONDS |
static String |
defaultDateFormat |
static String |
defaultLocalDateFormat |
static int |
HOURS_PER_DAY |
static int |
MINUTES_PER_HOUR |
static int |
SECONDS_PER_DAY |
static int |
SECONDS_PER_MINUTE |
| Modifier and Type | Method and Description |
|---|---|
static String |
format(BigDecimal date,
Boolean use1904windowing,
String dateFormat)
Format date
|
static String |
format(Date date)
Format date
|
static String |
format(Date date,
String dateFormat)
Format date
|
static String |
format(LocalDate date,
String dateFormat)
Format date
|
static String |
format(LocalDate date,
String dateFormat,
Locale local)
Format date
|
static String |
format(LocalDateTime date,
String dateFormat)
Format date
|
static String |
format(LocalDateTime date,
String dateFormat,
Locale local)
Format date
|
static Calendar |
getJavaCalendar(double date,
boolean use1904windowing,
TimeZone timeZone,
boolean roundSeconds)
Get EXCEL date as Java Calendar with given time zone.
|
static Date |
getJavaDate(double date,
boolean use1904windowing)
Given an Excel date with either 1900 or 1904 date windowing,
converts it to a java.util.Date.
|
static LocalDate |
getLocalDate(double date,
boolean use1904windowing)
Given an Excel date with either 1900 or 1904 date windowing,
converts it to a java.time.LocalDate.
|
static LocalDateTime |
getLocalDateTime(double date,
boolean use1904windowing)
Given an Excel date with either 1900 or 1904 date windowing,
converts it to a java.time.LocalDateTime.
|
static boolean |
isADateFormat(Short formatIndex,
String formatString)
Determine if it is a date format.
|
static boolean |
isADateFormatUncached(Short formatIndex,
String formatString)
Determine if it is a date format.
|
static boolean |
isInternalDateFormat(short format)
Given a format ID this will check whether the format represents an internal excel date format or not.
|
static boolean |
isValidExcelDate(double value)
Given a double, checks if it is a valid Excel date.
|
static Date |
parseDate(String dateString)
convert string to date
|
static Date |
parseDate(String dateString,
String dateFormat)
convert string to date
|
static LocalDate |
parseLocalDate(String dateString,
String dateFormat,
Locale local)
convert string to date
|
static LocalDateTime |
parseLocalDateTime(String dateString,
String dateFormat,
Locale local)
convert string to date
|
static void |
removeThreadLocalCache() |
static void |
setCalendar(Calendar calendar,
int wholeDays,
int millisecondsInDay,
boolean use1904windowing,
boolean roundSeconds) |
static String |
switchDateFormat(String dateString)
switch date format
|
public static final String DATE_FORMAT_10
public static final String DATE_FORMAT_14
public static final String DATE_FORMAT_16
public static final String DATE_FORMAT_16_FORWARD_SLASH
public static final String DATE_FORMAT_17
public static final String DATE_FORMAT_19
public static final String DATE_FORMAT_19_FORWARD_SLASH
public static String defaultDateFormat
public static String defaultLocalDateFormat
public static final int SECONDS_PER_MINUTE
public static final int MINUTES_PER_HOUR
public static final int HOURS_PER_DAY
public static final int SECONDS_PER_DAY
public static final long DAY_MILLISECONDS
public static Date parseDate(String dateString, String dateFormat) throws ParseException
dateString - dateFormat - ParseExceptionpublic static LocalDateTime parseLocalDateTime(String dateString, String dateFormat, Locale local)
dateString - dateFormat - local - public static LocalDate parseLocalDate(String dateString, String dateFormat, Locale local)
dateString - dateFormat - local - public static Date parseDate(String dateString) throws ParseException
dateString - ParseExceptionpublic static String switchDateFormat(String dateString)
dateString - public static String format(Date date)
yyyy-MM-dd HH:mm:ss
date - public static String format(Date date, String dateFormat)
date - dateFormat - public static String format(LocalDateTime date, String dateFormat, Locale local)
date - dateFormat - public static String format(LocalDate date, String dateFormat)
date - dateFormat - public static String format(LocalDate date, String dateFormat, Locale local)
date - dateFormat - public static String format(LocalDateTime date, String dateFormat)
date - dateFormat - public static String format(BigDecimal date, Boolean use1904windowing, String dateFormat)
date - dateFormat - public static Date getJavaDate(double date, boolean use1904windowing)
date - The Excel date.use1904windowing - true if date uses 1904 windowing,
or false if using 1900 date windowing.public static Calendar getJavaCalendar(double date, boolean use1904windowing, TimeZone timeZone, boolean roundSeconds)
date - The Excel date.use1904windowing - true if date uses 1904 windowing,
or false if using 1900 date windowing.timeZone - The TimeZone to evaluate the date inroundSeconds - round to closest secondpublic static void setCalendar(Calendar calendar, int wholeDays, int millisecondsInDay, boolean use1904windowing, boolean roundSeconds)
public static boolean isValidExcelDate(double value)
value - the double valuepublic static LocalDateTime getLocalDateTime(double date, boolean use1904windowing)
date - The Excel date.use1904windowing - true if date uses 1904 windowing,
or false if using 1900 date windowing.public static LocalDate getLocalDate(double date, boolean use1904windowing)
date - The Excel date.use1904windowing - true if date uses 1904 windowing,
or false if using 1900 date windowing.public static boolean isADateFormat(Short formatIndex, String formatString)
formatIndex - formatString - public static boolean isADateFormatUncached(Short formatIndex, String formatString)
formatIndex - formatString - public static boolean isInternalDateFormat(short format)
isADateFormat(Short, String)public static void removeThreadLocalCache()
Copyright © 2018–2024 Alibaba Group. All rights reserved.