Java Date Time - OffsetDateTime toString() example








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;

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.