OffsetTime parse(CharSequence text, DateTimeFormatter formatter) example

Description

OffsetTime parse(CharSequence text, DateTimeFormatter formatter) creates an instance of OffsetTime from a text string using a specific formatter.

Syntax

parse has the following syntax.


public static OffsetTime parse(CharSequence text,   DateTimeFormatter formatter)

Example

The following example shows how to use parse.


import java.time.OffsetTime;
import java.time.format.DateTimeFormatter;
/*from  w w w .  j a v  a  2 s.c o  m*/
public class Main {
  public static void main(String[] args) {
    OffsetTime m = OffsetTime.parse("18:26:06.325-07:00",DateTimeFormatter.ISO_OFFSET_TIME);

    System.out.println(m);

  }
}

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