|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectcom.extentech.ExtenXLS.DateConverter
public class DateConverter
Provides methods for conversion to and from Excel serial date values.
Excel stores dates as the number of days since midnight on January 1, 1900. Times are represented as fractional days. For example, 6:00 AM on February 2, 1900 is represented as 33.25. Excel incorrectly treats 1900 as a leap year, so serial dates after February 28, 1900 are one higher than they otherwise should be and the value 60 is unmapped. It also interprets the value 0 as January 0, 1900.
Excel does not support negative serial date values, so it cannot handle
dates prior to 1900. It also does not currently accept date values with a
year of 10000 or greater. ExtenXLS does not currently support negative date
values, but this feature is planned. If you wish to restrict the output to
the subset of values supported by Excel, you may enable input validation by
calling setValidate(boolean).
Due to the inherent inaccuracy of floating-point types, values from this class can only be guaranteed to equal values generated by Excel to eight decimal places. This provides accuracy to the unit milliseconds, the maximum precision of Java's date classes. Accuracy outside the range supported by Excel is not guaranteed and will degrade as the values get farther from zero.
| Field Summary | |
|---|---|
int |
DEBUGLEVEL
Deprecated. No longer used internally. Should not have been public. |
static int |
millsin8hours
Deprecated. No longer used internally. Should not have been public. |
static int |
millsinday
Deprecated. No longer used internally. Should not have been public. |
static int |
millsinhour
Deprecated. No longer used internally. Should not have been public. |
static int |
numdaysofEPOCH
Deprecated. No longer used internally. Should not have been public. |
static double |
xlsmillisec
Deprecated. No longer used internally. Should not have been public. |
static int |
xlsmultiplier
Deprecated. No longer used internally. Should not have been public. |
| Constructor Summary | |
|---|---|
DateConverter()
|
|
| Method Summary | |
|---|---|
static Calendar |
convertStringToCalendar(String dateStr)
Converts a string representation of a date into a valid calendar object date must be in format mm/dd/yy (or yyyy) |
static Calendar |
getCalendar()
Gets a clone of the calendar used for date calculation. |
static Calendar |
getCalendarFromCell(Cell cell)
Gets the Calendar for the given cell. |
static Calendar |
getCalendarFromCellWithPrecision(Cell cell,
int roundingCalendarField)
returns a Java Calendar from a CellHandle containing an Excel-formatted Date The Excel date format does not map 100% accurately to Java dates, due to the limitation of the precision of the Excel floating-point value record. |
static Calendar |
getCalendarFromNumber(double date)
Gets the Calendar for the given Excel serial date. |
static Calendar |
getCalendarFromNumber(Object number)
Deprecated. Use getCalendarFromNumber(double) instead. |
static Date |
getDateFromCell(CellHandle cell)
Gets the Date for the given cell. |
static Date |
getDateFromNumber(double date)
Gets the Date for the given Excel serial date. |
static Date |
getDateFromNumber(Object number)
Deprecated. Use getDateFromNumber(double) instead. |
static String |
getFormattedDateVal(CellHandle cell)
Deprecated. The date format handling in this method is wildly incorrect. It is retained only to provide compatibility with legacy ExtenXLS XML files. |
static Calendar |
getNonLocalizedCalendarFromNumber(Object number)
Deprecated. Identical to getDateFromNumber(Object). |
static Date |
getNonLocalizedDateFromNumber(Object number)
Deprecated. Identical to getDateFromNumber(Object). |
static long |
getNumDaysFrom00(String s)
gives the numeric number of days since 1900 for the given string date. |
static boolean |
getValidate()
Returns whether input validation is on. |
static double |
getXLSDateVal(Calendar cal)
Gets the Excel serial date value for the given Calendar object. |
static double |
getXLSDateVal(Date date)
Gets the Excel serial date for the given date in the default time zone. |
static boolean |
isDatePattern(String possibleDate)
Inspects a string to determine if it is a date. |
static boolean |
isParseableDateString(String str)
returns whether this method will work with your input string |
static Date |
parseDate(String s,
int pat)
Deprecated. The date format handling in this method is wildly incorrect. It is retained only to provide compatibility with legacy ExtenXLS XML files. |
static void |
setCalendar(Calendar cal)
Sets the calendar used to perform date calculation. |
static void |
setDaylightSavingsOffset(Date date)
Deprecated. Use Calendar instead. |
static void |
setValidate(boolean validate)
Sets whether to perform input validation. |
| Methods inherited from class java.lang.Object |
|---|
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
|---|
public static int numdaysofEPOCH
public static int millsinday
public static int millsin8hours
public static int millsinhour
public static double xlsmillisec
public static int xlsmultiplier
public int DEBUGLEVEL
| Constructor Detail |
|---|
public DateConverter()
| Method Detail |
|---|
public static Calendar getCalendar()
public static void setCalendar(Calendar cal)
cal - the calendar that should be used for date calculationspublic static boolean getValidate()
public static void setValidate(boolean validate)
public static boolean isParseableDateString(String str)
public static long getNumDaysFrom00(String s)
s - - the date to retrieve the numeric number of days.public static void setDaylightSavingsOffset(Date date)
Calendar instead.
date - the Date whose value should be changedpublic static double getXLSDateVal(Calendar cal)
cal - the Calendar to convert
public static double getXLSDateVal(Date date)
date - the date to be converted
public static Calendar getCalendarFromNumber(double date)
date - the Excel serial date to be interpreted
public static Date getDateFromNumber(double date)
number - a Number representing the serial date to be interpreted
public static Date getDateFromNumber(Object number)
getDateFromNumber(double) instead.
number - a Number representing the serial date to be interpreted
ClassCastException - if the passed object is not a Numberpublic static Date getNonLocalizedDateFromNumber(Object number)
getDateFromNumber(Object).
number - a Number representing the serial date to be interpreted
ClassCastException - if the passed object is not a Numberpublic static Calendar getCalendarFromNumber(Object number)
getCalendarFromNumber(double) instead.
date - the Excel serial date to be interpreted
ClassCastException - if the passed object is not a Numberpublic static Calendar getNonLocalizedCalendarFromNumber(Object number)
getDateFromNumber(Object).
number - a Number representing the serial date to be interpreted
ClassCastException - if the passed object is not a Numberpublic static Date getDateFromCell(CellHandle cell)
cell - a CellHandle whose value should be interpreted
public static Calendar getCalendarFromCellWithPrecision(Cell cell,
int roundingCalendarField)
public static Calendar getCalendarFromCell(Cell cell)
cell - a CellHandle whose value should be interpreted
public static boolean isDatePattern(String possibleDate)
possibleDate - the string to check for date formats
public static Calendar convertStringToCalendar(String dateStr)
dateStr -
public static String getFormattedDateVal(CellHandle cell)
public static Date parseDate(String s,
int pat)
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||