public abstract class Instants
extends java.lang.Object
timezones and vice versa| Modifier and Type | Field and Description |
|---|---|
static java.util.TimeZone |
UTC_TIMEZONE |
| Constructor and Description |
|---|
Instants() |
| Modifier and Type | Method and Description |
|---|---|
static long |
convertDate(long time,
java.util.TimeZone from,
java.util.TimeZone to)
Converts a given time from a
TimeZone to another |
static long |
convertDateToLocalTime(long time,
java.util.TimeZone to)
Converts a given time from UTC (Coordinated Universal Time) to the corresponding time in the specified
TimeZone |
static long |
convertDateToUTC(long time,
java.util.TimeZone from)
Converts a given time from the specified
TimeZone to the corresponding UTC (Coordinated Universal Time) time |
static java.util.Date |
of(int year)
Creates an UTC-based
Date using the provided year. |
static java.util.Date |
of(int year,
int month)
Creates an UTC-based
Date from the provided year and month. |
static java.util.Date |
of(int year,
int month,
int day)
Creates an UTC-based
Date from the provided year, month and day
Uses the current date and time, sets the specified year, month and day, and returns the Date converted to a UTC timestamp. |
static java.util.Date |
of(int year,
int month,
int day,
int hour)
Creates an UTC-based
Date from the provided year, month, day and hour. |
static java.util.Date |
of(int year,
int month,
int day,
int hour,
int minute)
Creates an UTC-based
Date from the provided year, month, day, hour and minute. |
static java.util.Date |
of(int year,
int month,
int day,
int hour,
int minute,
int second)
Creates an UTC-based
Date from the provided year, month, day, hour, minute and second. |
static java.util.Date |
of(int year,
int month,
int day,
int hour,
int minute,
int second,
int millisecond)
Creates an UTC-based
Date from the provided year, month, day, hour, minute and second. |
static java.lang.String |
toUtcIso8601(java.util.Date date)
Returns the UTC-normalized ISO 8601 representation of the specified date instance.
|
public static java.lang.String toUtcIso8601(java.util.Date date)
date - the date to format.public static long convertDateToLocalTime(long time,
java.util.TimeZone to)
TimeZonetime - the UTC instant to convert, represented as the number of milliseconds that have elapsed since midnight, January 1, 1970to - the target TimeZone for the conversionTimeZonepublic static long convertDateToUTC(long time,
java.util.TimeZone from)
TimeZone to the corresponding UTC (Coordinated Universal Time) timetime - the instant to convert, represented as the number of milliseconds that have elapsed since midnight, January 1, 1970from - the original TimeZonepublic static long convertDate(long time,
java.util.TimeZone from,
java.util.TimeZone to)
TimeZone to anothertime - the instant to convert, represented as the number of milliseconds that have elapsed since midnight, January 1, 1970 in the from TimeZonefrom - the original TimeZoneto - the target TimeZone for the conversionto TimeZonepublic static java.util.Date of(int year)
Date using the provided year.
Uses the current date and time, sets the specified year and returns the Date converted to a UTC timestamp.year - the year to representDatepublic static java.util.Date of(int year,
int month)
Date from the provided year and month.
Uses the current date and time, sets the specified year and month, and returns the Date converted to a UTC timestamp.year - the year to representmonth - the month-of-year to represent, from 0 (January) to 11 (December)Datepublic static java.util.Date of(int year,
int month,
int day)
Date from the provided year, month and day
Uses the current date and time, sets the specified year, month and day, and returns the Date converted to a UTC timestamp.year - the year to representmonth - the month-of-year to represent, from 0 (January) to 11 (December)day - the day-of-month to represent, from 1 to 31Datepublic static java.util.Date of(int year,
int month,
int day,
int hour)
Date from the provided year, month, day and hour.
Uses the current date and time, sets the specified year, month, day and hour, and returns the Date converted to a UTC timestamp.year - the year to representmonth - the month-of-year to represent, from 0 (January) to 11 (December)day - the day-of-month to represent, from 1 to 31hour - the hour-of-day to represent, from 0 to 23Datepublic static java.util.Date of(int year,
int month,
int day,
int hour,
int minute)
Date from the provided year, month, day, hour and minute.
Uses the current date and time, sets the specified year, month, day, hour and minute, and returns the Date converted to a UTC timestamp.year - the year to representmonth - the month-of-year to represent, from 0 (January) to 11 (December)day - the day-of-month to represent, from 1 to 31hour - the hour-of-day to represent, from 0 to 23minute - the minute-of-hour to represent, from 0 to 59Datepublic static java.util.Date of(int year,
int month,
int day,
int hour,
int minute,
int second)
Date from the provided year, month, day, hour, minute and second.
Uses the current date and time, sets the specified year, month, day, hour, minute and second, and returns the Date converted to a UTC timestamp.year - the year to representmonth - the month-of-year to represent, from 0 (January) to 11 (December)day - the day-of-month to represent, from 1 to 31hour - the hour-of-day to represent, from 0 to 23minute - the minute-of-hour to represent, from 0 to 59second - the second-of-hour to represent, from 0 to 59Datepublic static java.util.Date of(int year,
int month,
int day,
int hour,
int minute,
int second,
int millisecond)
Date from the provided year, month, day, hour, minute and second.
Uses the current date and time, sets the specified year, month, day, hour, minute and second, and returns the Date converted to a UTC timestamp.year - the YEAR to representmonth - the MONTH to represent, from 0 (January) to 11 (December)day - the DAY_OF_MONTH to represent, from 1 to 31hour - the HOUR_OF_DAY to represent, from 0 to 23minute - the MINUTE to represent, from 0 to 59second - the SECOND to represent, from 0 to 59millisecond - the MILLISECOND to represent, from 0 to 59DateCopyright © 2018-2022 Okta. All Rights Reserved.