|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectorg.threeten.bp.DateTimeUtils
public final class DateTimeUtils
A set of utilities to assist in bridging the gap to Java 8.
This class is not found in Java SE 8 but provides methods that are.
| Method Summary | |
|---|---|
static Date |
toDate(Instant instant)
Converts an Instant to a java.util.Date. |
static GregorianCalendar |
toGregorianCalendar(ZonedDateTime zdt)
Converts a ZonedDateTime to a Calendar. |
static Instant |
toInstant(Calendar calendar)
Converts a Calendar to an Instant. |
static Instant |
toInstant(Date utilDate)
Converts a java.util.Date to an Instant. |
static Instant |
toInstant(Timestamp sqlTimestamp)
Converts a java.sql.Timestamp to an Instant. |
static LocalDate |
toLocalDate(Date sqlDate)
Converts a java.sql.Date to a LocalDate. |
static LocalDateTime |
toLocalDateTime(Timestamp sqlTimestamp)
Converts a java.sql.Timestamp to a LocalDateTime. |
static LocalTime |
toLocalTime(Time sqlTime)
Converts a java.sql.Time to a LocalTime. |
static Date |
toSqlDate(LocalDate date)
Converts a LocalDate to a java.sql.Date. |
static Time |
toSqlTime(LocalTime time)
Converts a LocalTime to a java.sql.Time. |
static Timestamp |
toSqlTimestamp(Instant instant)
Converts an Instant to a java.sql.Timestamp. |
static Timestamp |
toSqlTimestamp(LocalDateTime dateTime)
Converts a LocalDateTime to a java.sql.Timestamp. |
static TimeZone |
toTimeZone(ZoneId zoneId)
Converts a ZoneId to a TimeZone. |
static ZonedDateTime |
toZonedDateTime(Calendar calendar)
Converts a Calendar to a ZonedDateTime. |
static ZoneId |
toZoneId(TimeZone timeZone)
Converts a TimeZone to a ZoneId. |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Method Detail |
|---|
public static Instant toInstant(Date utilDate)
java.util.Date to an Instant.
utilDate - the util date, not null
public static Date toDate(Instant instant)
Instant to a java.util.Date.
Fractions of the instant smaller than milliseconds will be dropped.
instant - the instant, not null
IllegalArgumentException - if the conversion failspublic static Instant toInstant(Calendar calendar)
Calendar to an Instant.
calendar - the calendar, not null
public static ZonedDateTime toZonedDateTime(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 null
public static 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 null
IllegalArgumentException - if the conversion failspublic static ZoneId toZoneId(TimeZone timeZone)
TimeZone to a ZoneId.
timeZone - the time-zone, not null
public static TimeZone toTimeZone(ZoneId zoneId)
ZoneId to a TimeZone.
zoneId - the zone, not null
public static LocalDate toLocalDate(Date sqlDate)
java.sql.Date to a LocalDate.
sqlDate - the SQL date, not null
public static Date toSqlDate(LocalDate date)
LocalDate to a java.sql.Date.
date - the local date, not null
public static LocalTime toLocalTime(Time sqlTime)
java.sql.Time to a LocalTime.
sqlTime - the SQL time, not null
public static Time toSqlTime(LocalTime time)
LocalTime to a java.sql.Time.
time - the local time, not null
public static Timestamp toSqlTimestamp(LocalDateTime dateTime)
LocalDateTime to a java.sql.Timestamp.
dateTime - the local date-time, not null
public static LocalDateTime toLocalDateTime(Timestamp sqlTimestamp)
java.sql.Timestamp to a LocalDateTime.
sqlTimestamp - the SQL timestamp, not null
public static Timestamp toSqlTimestamp(Instant instant)
Instant to a java.sql.Timestamp.
instant - the instant, not null
public static Instant toInstant(Timestamp sqlTimestamp)
java.sql.Timestamp to an Instant.
sqlTimestamp - the SQL timestamp, not null
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||