Example usage for java.time OffsetDateTime getSecond

List of usage examples for java.time OffsetDateTime getSecond

Introduction

In this page you can find the example usage for java.time OffsetDateTime 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) {
    OffsetDateTime o = OffsetDateTime.now();

    System.out.println(o.getSecond());
}

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

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

    Object timeObj = mapper.readValue(content, Object.class);
    SqpTimestamp sqpTimestamp = SqpTimestamp.fromJsonFormatValue(timeObj);

    OffsetDateTime timestamp = sqpTimestamp.asOffsetDateTime();
    assertThat(timestamp.getHour(), is(13));
    assertThat(timestamp.getMinute(), is(52));
    assertThat(timestamp.getSecond(), is(5));
    assertThat(timestamp.getNano(), is(123456));
    assertThat(timestamp.getOffset().getTotalSeconds(), is(7260));

    assertThat(timestamp.getYear(), is(2015));
    assertThat(timestamp.getMonth(), is(Month.JUNE));
    assertThat(timestamp.getDayOfMonth(), is(28));
}

From source file:org.openmhealth.schema.serializer.Rfc3339OffsetDateTimeSerializer.java

@Override
public void serialize(OffsetDateTime instant, JsonGenerator generator, SerializerProvider provider)
        throws IOException {

    StringBuilder builder = new StringBuilder();

    builder.append(instant.toLocalDateTime().toString());

    if (instant.getSecond() == 0 && instant.getNano() == 0) {
        builder.append(":00");
    }//  ww w .  j  a v  a2s  .c o m

    builder.append(instant.getOffset().toString());

    generator.writeString(builder.toString());
}