[]
Use this type when you need to exchange date values between Java code and the numeric date representation used by Excel and OLE Automation.
LocalDateTime appointment = LocalDateTime.of(2024, 1, 15, 8, 30);
double oaDate = DateInfo.ToOADate(appointment);
LocalDateTime restored = DateInfo.FromOADateAsLocalDateTime(oaDate);
static DateFromOADate(double value) static LocalDateTimeFromOADateAsLocalDateTime(double value) LocalDateTime according to an OADate value.static doubleToOADate(LocalDateTime localDateTime) LocalDateTime.static doubleCalendar.static doubleDate.Date. Use this method to convert a Java Date value to the numeric date representation used by Excel and OLE Automation.
Calendar calendar = new GregorianCalendar(2024, Calendar.JANUARY, 15, 8, 30, 0);
Date date = calendar.getTime();
double oaDate = DateInfo.ToOADate(date);
Calendar. Use this method to convert a Java calendar value to the numeric date representation used by Excel.
Calendar calendar = Calendar.getInstance();
calendar.set(2024, Calendar.JANUARY, 15, 8, 30, 0);
calendar.set(Calendar.MILLISECOND, 0);
double oaDate = DateInfo.ToOADate(calendar);
calendar - The Calendar object to convert.LocalDateTime. Use this method to convert a Java date-time value to the numeric date representation used by Excel.
LocalDateTime localDateTime = LocalDateTime.of(2024, 1, 15, 8, 30);
double oaDate = DateInfo.ToOADate(localDateTime);
localDateTime - The LocalDateTime object to convert.FromOADateAsLocalDateTime(double) instead.Date. This method returns the Date that corresponds to the specified OADate value.
value - The OADate value to convert.Date that corresponds to the specified OADate value.LocalDateTime according to an OADate value.Use this method to convert an OLE Automation date value to a LocalDateTime. To convert a LocalDateTime back to an OADate value, use ToOADate(LocalDateTime).
double oaDate = 45292.5;
LocalDateTime dateTime = DateInfo.FromOADateAsLocalDateTime(oaDate);
int hour = dateTime.getHour();
value - The OADate value to convert.LocalDateTime.
FromOADateAsLocalDateTime(double)instead.