Example usage for java.time OffsetTime getHour

List of usage examples for java.time OffsetTime getHour

Introduction

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

Prototype

public int getHour() 

Source Link

Document

Gets the hour-of-day field.

Usage

From source file:Main.java

public static void main(String[] args) {
    OffsetTime m = OffsetTime.now();
    int n = m.getHour();
    System.out.println(n);//from   w  w  w  .  j a va  2s .  c  o  m

}

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));
}