Search in sources :

Example 1 with Instant

use of org.apache.logging.log4j.core.time.Instant in project logging-log4j2 by apache.

the class InstantAttributeConverterTest method testConvert01.

@Test
public void testConvert01() {
    final MutableInstant instant = new MutableInstant();
    instant.initFromEpochSecond(1234567, 89012);
    final String converted = this.converter.convertToDatabaseColumn(instant);
    assertNotNull("The converted value should not be null.", converted);
    assertEquals("The converted value is not correct.", "1234567,89012", converted);
    final Instant reversed = this.converter.convertToEntityAttribute(converted);
    assertNotNull("The reversed value should not be null.", reversed);
    assertEquals("epoch sec", 1234567, reversed.getEpochSecond());
    assertEquals("nanoOfSecond", 89012, reversed.getNanoOfSecond());
}
Also used : MutableInstant(org.apache.logging.log4j.core.time.MutableInstant) Instant(org.apache.logging.log4j.core.time.Instant) MutableInstant(org.apache.logging.log4j.core.time.MutableInstant) Test(org.junit.Test)

Aggregations

Instant (org.apache.logging.log4j.core.time.Instant)1 MutableInstant (org.apache.logging.log4j.core.time.MutableInstant)1 Test (org.junit.Test)1