org.apache.poi.hssf.usermodel
Class HSSFDateUtil
java.lang.Object
|
+--org.apache.poi.hssf.usermodel.HSSFDateUtil
- public class HSSFDateUtil
- extends java.lang.Object
Contains methods for dealing with Excel dates.
- Author:
- Michael Harhen, Glen Stampoultzis (glens at apache.org)
Method Summary |
static double |
getExcelDate(java.util.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 java.util.Date |
getJavaDate(double date)
Given a excel date, converts it into a Date. |
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 |
isValidExcelDate(double value)
Given a double, checks if it is a valid Excel date. |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
getExcelDate
public static double getExcelDate(java.util.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. Fractional days represent hours, minutes, and seconds.
- Parameters:
date
- the Date- Returns:
- Excel representation of Date (-1 if error - test for error by checking for less than 0.1)
getJavaDate
public static java.util.Date getJavaDate(double date)
- Given a excel date, converts it into a Date.
- Parameters:
date
- the Excel Date- Returns:
- Java representation of a date (null if error)
isCellDateFormatted
public 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.
isValidExcelDate
public static boolean isValidExcelDate(double value)
- Given a double, checks if it is a valid Excel date.
- Parameters:
value
- the double value- Returns:
- true if valid
Copyright © 2002 Apache jakarta-poi project. All Rights Reserved.