public final class DateTimeUtils
extends java.lang.Object
This class is not found in Java SE 8 but provides methods that are.
| Modifier and Type | Method and Description |
|---|---|
static java.util.Date |
toDate(Instant instant)
Converts an
Instant to a java.util.Date. |
static java.util.GregorianCalendar |
toGregorianCalendar(ZonedDateTime zdt)
Converts a
ZonedDateTime to a Calendar. |
static Instant |
toInstant(java.util.Calendar calendar)
Converts a
Calendar to an Instant. |
static Instant |
toInstant(java.util.Date utilDate)
Converts a
java.util.Date to an Instant. |
static Instant |
toInstant(java.sql.Timestamp sqlTimestamp)
Converts a
java.sql.Timestamp to an Instant. |
static LocalDate |
toLocalDate(java.sql.Date sqlDate)
Converts a
java.sql.Date to a LocalDate. |
static LocalDateTime |
toLocalDateTime(java.sql.Timestamp sqlTimestamp)
Converts a
java.sql.Timestamp to a LocalDateTime. |
static LocalTime |
toLocalTime(java.sql.Time sqlTime)
Converts a
java.sql.Time to a LocalTime. |
static java.sql.Date |
toSqlDate(LocalDate date)
Converts a
LocalDate to a java.sql.Date. |
static java.sql.Time |
toSqlTime(LocalTime time)
Converts a
LocalTime to a java.sql.Time. |
static java.sql.Timestamp |
toSqlTimestamp(Instant instant)
Converts an
Instant to a java.sql.Timestamp. |
static java.sql.Timestamp |
toSqlTimestamp(LocalDateTime dateTime)
Converts a
LocalDateTime to a java.sql.Timestamp. |
static java.util.TimeZone |
toTimeZone(ZoneId zoneId)
Converts a
ZoneId to a TimeZone. |
static ZonedDateTime |
toZonedDateTime(java.util.Calendar calendar)
Converts a
Calendar to a ZonedDateTime. |
static ZoneId |
toZoneId(java.util.TimeZone timeZone)
Converts a
TimeZone to a ZoneId. |
public static Instant toInstant(java.util.Date utilDate)
java.util.Date to an Instant.utilDate - the util date, not nullpublic static java.util.Date toDate(Instant instant)
Instant to a java.util.Date.
Fractions of the instant smaller than milliseconds will be dropped.
instant - the instant, not nulljava.lang.IllegalArgumentException - if the conversion failspublic static Instant toInstant(java.util.Calendar calendar)
Calendar to an Instant.calendar - the calendar, not nullpublic static ZonedDateTime toZonedDateTime(java.util.Calendar calendar)
Calendar to a ZonedDateTime.
Note that GregorianCalendar supports a Julian-Gregorian cutover
date and ZonedDateTime does not so some differences will occur.
calendar - the calendar, not nullpublic static java.util.GregorianCalendar toGregorianCalendar(ZonedDateTime zdt)
ZonedDateTime to a Calendar.
The resulting GregorianCalendar is pure Gregorian and uses
ISO week definitions, starting on Monday and with 4 days in a minimal week.
Fractions of the instant smaller than milliseconds will be dropped.
zdt - the zoned date-time, not nulljava.lang.IllegalArgumentException - if the conversion failspublic static ZoneId toZoneId(java.util.TimeZone timeZone)
TimeZone to a ZoneId.timeZone - the time-zone, not nullpublic static java.util.TimeZone toTimeZone(ZoneId zoneId)
ZoneId to a TimeZone.zoneId - the zone, not nullpublic static LocalDate toLocalDate(java.sql.Date sqlDate)
java.sql.Date to a LocalDate.sqlDate - the SQL date, not nullpublic static java.sql.Date toSqlDate(LocalDate date)
LocalDate to a java.sql.Date.localDate - the local date, not nullpublic static LocalTime toLocalTime(java.sql.Time sqlTime)
java.sql.Time to a LocalTime.sqlTime - the SQL time, not nullpublic static java.sql.Time toSqlTime(LocalTime time)
LocalTime to a java.sql.Time.localTime - the local time, not nullpublic static java.sql.Timestamp toSqlTimestamp(LocalDateTime dateTime)
LocalDateTime to a java.sql.Timestamp.dateTime - the local date-time, not nullpublic static LocalDateTime toLocalDateTime(java.sql.Timestamp sqlTimestamp)
java.sql.Timestamp to a LocalDateTime.sqlTimestamp - the SQL timestamp, not nullpublic static java.sql.Timestamp toSqlTimestamp(Instant instant)
Instant to a java.sql.Timestamp.instant - the instant, not nullpublic static Instant toInstant(java.sql.Timestamp sqlTimestamp)
java.sql.Timestamp to an Instant.sqlTimestamp - the SQL timestamp, not nullCopyright © 2014. All Rights Reserved.