OffsetDateTime toString() example

Description

OffsetDateTime toString() outputs this date-time as a String, such as 2014-12-03T10:15:30+01:00.

Syntax

toString has the following syntax.


public String toString()

Example

The following example shows how to use toString.


import java.time.OffsetDateTime;
/*from w  ww. j  a  v a  2  s. co m*/
public class Main {
  public static void main(String[] args) {
    OffsetDateTime o = OffsetDateTime.MAX;
    
    System.out.println(o.toString());
  }
}

The code above generates the following result.





















Home »
  Java Date Time »
    java.time Reference »




Clock
DayOfWeek
Duration
Instant
LocalDate
LocalDateTime
LocalTime
Month
MonthDay
OffsetDateTime
OffsetTime
Period
Year
YearMonth
ZonedDateTime
ZoneId
ZoneOffset