Example usage for org.joda.time.format DateTimeFormatterBuilder appendFixedDecimal

List of usage examples for org.joda.time.format DateTimeFormatterBuilder appendFixedDecimal

Introduction

In this page you can find the example usage for org.joda.time.format DateTimeFormatterBuilder appendFixedDecimal.

Prototype

public DateTimeFormatterBuilder appendFixedDecimal(DateTimeFieldType fieldType, int numDigits) 

Source Link

Document

Instructs the printer to emit a field value as a fixed-width decimal number (smaller numbers will be left-padded with zeros), and the parser to expect an unsigned decimal number with the same fixed width.

Usage

From source file:com.github.fge.jsonschema.format.draftv3.DateAttribute.java

License:LGPL

@Override
protected DateTimeFormatter getFormatter() {
    DateTimeFormatterBuilder builder = new DateTimeFormatterBuilder();

    builder = builder.appendFixedDecimal(year(), 4).appendLiteral('-').appendFixedDecimal(monthOfYear(), 2)
            .appendLiteral('-').appendFixedDecimal(dayOfMonth(), 2);

    return builder.toFormatter();
}

From source file:com.github.fge.jsonschema.format.draftv3.TimeAttribute.java

License:LGPL

@Override
protected DateTimeFormatter getFormatter() {
    DateTimeFormatterBuilder builder = new DateTimeFormatterBuilder();

    builder = builder.appendFixedDecimal(hourOfDay(), 2).appendLiteral(':')
            .appendFixedDecimal(minuteOfHour(), 2).appendLiteral(':').appendFixedDecimal(secondOfMinute(), 2);

    return builder.toFormatter();
}

From source file:org.kalypso.ogc.sensor.util.TimestampHelper.java

License:Open Source License

/**
 * This function creates the date time formatter.
 * /* w ww . j  a  va  2  s  .  co m*/
 * @return The date time formater.
 */
private static DateTimeFormatter createDateTimeFormatter() {
    /* Create the date time formatter builder. */
    final DateTimeFormatterBuilder builder = new DateTimeFormatterBuilder();
    builder.appendFixedDecimal(DateTimeFieldType.hourOfDay(), 2);
    builder.appendLiteral(':'); // $NON-NLS-1$
    builder.appendFixedDecimal(DateTimeFieldType.minuteOfHour(), 2);

    return builder.toFormatter();
}