Example usage for java.time OffsetTime getOffset

List of usage examples for java.time OffsetTime getOffset

Introduction

In this page you can find the example usage for java.time OffsetTime getOffset.

Prototype

public ZoneOffset getOffset() 

Source Link

Document

Gets the zone offset, such as '+01:00'.

Usage

From source file:Main.java

public static void main(String[] args) {
    OffsetTime m = OffsetTime.now();
    ZoneOffset z = m.getOffset();
    System.out.println(z);// ww  w .j a  v  a2s  .com

}

From source file:io.sqp.core.types.SqpTimeTest.java

@Test
public void CanDecodeFromJson() throws Exception {
    String content = "[[13, 52, 5, 123456],7260]";
    ObjectMapper mapper = JacksonObjectMapperFactory.objectMapper(DataFormat.Text);

    Object timeObj = mapper.readValue(content, Object.class);
    SqpTime sqpTime = SqpTime.fromJsonFormatValue(timeObj);

    assertThat(sqpTime.hasOffset(), is(true));
    OffsetTime offsetTime = sqpTime.asOffsetTime();
    assertThat(offsetTime.getHour(), is(13));
    assertThat(offsetTime.getMinute(), is(52));
    assertThat(offsetTime.getSecond(), is(5));
    assertThat(offsetTime.getNano(), is(123456));
    assertThat(offsetTime.getOffset().getTotalSeconds(), is(7260));
}

From source file:io.sqp.core.types.SqpTimeTest.java

@Test
public void CanDecodeFromJsonWithoutOffset() throws Exception {
    String content = "[[13, 52, 5, 123456]]";
    ObjectMapper mapper = JacksonObjectMapperFactory.objectMapper(DataFormat.Text);

    Object timeObj = mapper.readValue(content, Object.class);
    SqpTime sqpTime = SqpTime.fromJsonFormatValue(timeObj);

    assertThat(sqpTime.hasOffset(), is(false));
    OffsetTime offsetTime = sqpTime.asOffsetTime();
    assertThat(offsetTime.getHour(), is(13));
    assertThat(offsetTime.getMinute(), is(52));
    assertThat(offsetTime.getSecond(), is(5));
    assertThat(offsetTime.getNano(), is(123456));
    assertThat(offsetTime.getOffset().getTotalSeconds(), is(0));
}