public class HSSFDateUtil extends Object
Modifier and Type | Field and Description |
---|---|
private static int |
BAD_DATE |
private static long |
DAY_MILLISECONDS |
Modifier | Constructor and Description |
---|---|
private |
HSSFDateUtil() |
Modifier and Type | Method and Description |
---|---|
private static int |
absoluteDay(Calendar cal)
Given a Calendar, return the number of days since 1900/12/31.
|
private static int |
daysInPriorYears(int yr)
Return the number of days in prior years since 1900
|
private static Calendar |
dayStart(Calendar cal) |
static double |
getExcelDate(Date date)
Given a Date, converts it into a double representing its internal Excel representation,
which is the number of days since 1/1/1900.
|
static Date |
getJavaDate(double date)
Given a excel date, converts it into a Date.
|
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 boolean |
isADateFormat(int formatIndex,
String formatString)
Given a format ID and its format String, will check to see if the
format represents a date format or not.
|
static boolean |
isCellDateFormatted(HSSFCell cell)
Check if a cell contains a date
Since dates are stored internally in Excel as double values
we infer it is a date if it is formatted as such.
|
static boolean |
isCellInternalDateFormatted(HSSFCell cell)
Check if a cell contains a date, checking only for internal
excel date formats.
|
static boolean |
isInternalDateFormat(int 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.
|
private static final int BAD_DATE
private static final long DAY_MILLISECONDS
public static double getExcelDate(Date date)
date
- the Datepublic static Date getJavaDate(double date)
date
- the Excel DategetJavaDate(double,boolean)
public static Date getJavaDate(double date, boolean use1904windowing)
TimeZone
in Java uses Daylight
Saving Time then the conversion back to an Excel date may not give
the same value, that is the comparison
excelDate == getExcelDate(getJavaDate(excelDate,false))
is not always true. For example if default timezone is
Europe/Copenhagen
, on 2004-03-28 the minute after
01:59 CET is 03:00 CEST, if the excel date represents a time between
02:00 and 03:00 then it is converted to past 03:00 summer timedate
- The Excel date.use1904windowing
- true if date uses 1904 windowing,
or false if using 1900 date windowing.TimeZone
public static boolean isADateFormat(int formatIndex, String formatString)
formatIndex
- The index of the format, eg from ExtendedFormatRecord.getFormatIndexformatString
- The format string, eg from FormatRecord.getFormatStringisInternalDateFormat(int)
public static boolean isInternalDateFormat(int format)
isADateFormat(int, java.lang.String)
public static boolean isCellDateFormatted(HSSFCell cell)
public static boolean isCellInternalDateFormatted(HSSFCell cell)
public static boolean isValidExcelDate(double value)
value
- the double valueprivate static int absoluteDay(Calendar cal)
cal
- the CalendarIllegalArgumentException
- if date is invalidprivate static int daysInPriorYears(int yr)
yr
- a year (1900 < yr < 4000)IllegalArgumentException
- if year is outside of range.Copyright © 2016 Open Microscopy Environment