com.ethlo.time

What is it

com.ethlo.time provides utilities for parsing and producing the date and time formats that you are likely to run into on the internet. Namely, RFC-3339 timestamps and the W3C date and time Formats.

Why use it

While the java.time packages provide generic date and time parsing and can support a wide variety of formats, you still need to know what formats to pick. You also need to pick the same ones everywhere in your program.

This streamlines that process for the common case of working with time information you got from, or you want to put out into, the internet.

It also is reportedly faster than the code you would produce using the generic APIs.

Getting Started

import java.time.OffsetDateTime;
import com.ethlo.time.DateTime;
import com.ethlo.time.ITU;

void main() {
    DateTime dateTime
            = ITU.parseLenient("2012-12-27T19:07Z");
    // 2012-12-27T19:07Z
    System.out.println(dateTime);

    OffsetDateTime offsetDateTime
            = ITU.parseDateTime("2012-12-27T19:07:22.123456789-03:00");

    // 2012-12-27T22:07:22Z
    System.out.println(ITU.formatUtc(offsetDateTime));

    // 2012-12-27T22:07:22.123Z
    System.out.println(ITU.formatUtcMilli(offsetDateTime));

    // 2012-12-27T22:07:22.123456Z
    System.out.println(ITU.formatUtcMicro(offsetDateTime));

    // 2012-12-27T22:07:22.123456789Z
    System.out.println(ITU.formatUtcNano(offsetDateTime));
}

<- Index