- java.time - Discussion
- java.time - Month
- java.time - ZoneOffset
- java.time - ZoneId
- java.time - ZonedDateTime
- java.time - YearMonth
- java.time - Year
- java.time - Period
- java.time - OffsetTime
- java.time - OffsetDateTime
- java.time - MonthDay
- java.time - LocalTime
- java.time - LocalDateTime
- java.time - LocalDate
- java.time - Instant
- java.time - Duration
- java.time - Clock
- java.time - Home
Selected Reading
- Who is Who
- Computer Glossary
- HR Interview Questions
- Effective Resume Writing
- Questions and Answers
- UPSC IAS Exams Notes
java.time.Instant Class
Introduction
The java.time.Instant class models a single instantaneous point on the time-pne.
Class declaration
Following is the declaration for java.time.Instant class −
pubpc final class Instant extends Object implements Temporal, TemporalAdjuster, Comparable, Seriapzable
Field
Following are the fields for Java.time.Instant class −
static Instant EPOCH − Constant for the 1970-01-01T00:00:00Z epoch instant.
static Instant MAX − The maximum supported Instant, 1000000000-12-31T23:59:59.999999999Z .
static Instant MIN − The minimum supported Instant, -1000000000-01-01T00:00Z .
Class methods
Sr.No. | Method & Description |
---|---|
1 | Adjusts the specified temporal object to have this instant. |
2 | Combines this instant with an offset to create an OffsetDateTime. |
3 | Combines this instant with a time-zone to create a ZonedDateTime. |
4 | Compares this instant to the specified instant. |
5 | Checks if this instant is equal to the specified instant. |
6 | Obtains an instance of Instant from a temporal object. |
7 | Gets the value of the specified field from this instant as an int. |
8 | Gets the number of seconds from the Java epoch of 1970-01-01T00:00:00Z. |
9 | Gets the value of the specified field from this instant as a long. |
10 | Gets the number of nanoseconds, later along the time-pne, from the start of the second. |
11 | Returns a hash code for this instant. |
12 | Checks if this instant is after the specified instant. |
13 | Checks if this instant is before the specified instant. |
14 | Checks if the specified field is supported. |
15 | Checks if the specified unit is supported. |
16 | Returns a copy of this instant with the specified amount subtracted. |
17 | Returns a copy of this instant with the specified amount subtracted. |
18 | Returns a copy of this instant with the specified duration in milpseconds subtracted. |
19 | Returns a copy of this instant with the specified duration in nanoseconds subtracted. |
20 | Returns a copy of this instant with the specified duration in seconds subtracted. |
21 | Obtains the current instant from the system clock. |
22 | Obtains the current instant from the specified clock. |
23 | Obtains an instance of Instant using milpseconds from the epoch of 1970-01-01T00:00:00Z. |
24 | Obtains an instance of Instant using seconds from the epoch of 1970-01-01T00:00:00Z. |
25 | Obtains an instance of Instant using seconds from the epoch of 1970-01-01T00:00:00Z and nanosecond fraction of second. |
26 | Obtains an instance of Instant from a text string such as 2007-12-03T10:15:30.00Z. |
27 | Returns a copy of this instant with the specified amount added. |
28 | Returns a copy of this instant with the specified amount added. |
29 | Returns a copy of this instant with the specified duration in milpseconds added. |
30 | Returns a copy of this instant with the specified duration in nanoseconds added. |
31 | Returns a copy of this instant with the specified duration in seconds added. |
32 | Queries this instant using the specified query. |
33 | Gets the range of vapd values for the specified field. |
34 | Converts this instant to the number of milpseconds from the epoch of 1970-01-01T00:00:00Z. |
35 | A string representation of this instant using ISO-8601 representation. |
36 | Returns a copy of this Instant truncated to the specified unit. |
37 | Calculates the amount of time until another instant in terms of the specified unit. |
38 | Returns an adjusted copy of this instant. |
39 | Returns a copy of this instant with the specified field set to a new value. |
Methods inherited
This class inherits methods from the following classes −
Java.lang.Object