Example usage for java.time OffsetTime getSecond

List of usage examples for java.time OffsetTime getSecond

Introduction

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

Prototype

public int getSecond() 

Source Link

Document

Gets the second-of-minute field.

Usage

From source file:Main.java

public static void main(String[] args) {
    OffsetTime m = OffsetTime.now();
    int n = m.getSecond();
    System.out.println(n);/*from w  w  w  . j ava  2 s  .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));
}