Example usage for org.springframework.format.datetime.joda ReadablePartialPrinter ReadablePartialPrinter

List of usage examples for org.springframework.format.datetime.joda ReadablePartialPrinter ReadablePartialPrinter

Introduction

In this page you can find the example usage for org.springframework.format.datetime.joda ReadablePartialPrinter ReadablePartialPrinter.

Prototype

public ReadablePartialPrinter(DateTimeFormatter formatter) 

Source Link

Document

Create a new ReadableInstantPrinter.

Usage

From source file:cherry.foundation.type.format.CustomDateTimeFormatAnnotationFormatterFactory.java

@Override
public Printer<?> getPrinter(CustomDateTimeFormat annotation, Class<?> fieldType) {
    if (fieldType == LocalDate.class) {
        DateTimeFormatterBuilder toPrint = builder(dateToPrint);
        return new ReadablePartialPrinter(toPrint.toFormatter());
    } else if (fieldType == LocalTime.class) {
        DateTimeFormatterBuilder toPrint = builder(timeToPrint);
        return new ReadablePartialPrinter(toPrint.toFormatter());
    } else if (fieldType == LocalDateTime.class) {
        DateTimeFormatterBuilder toPrint = builder(dateToPrint).appendPattern(delimiterToPrint)
                .appendPattern(timeToPrint);
        return new ReadablePartialPrinter(toPrint.toFormatter());
    } else if (fieldType == DateTime.class) {
        DateTimeFormatterBuilder toPrint = builder(dateToPrint).appendPattern(delimiterToPrint)
                .appendPattern(timeToPrint);
        return new ReadableInstantPrinter(toPrint.toFormatter());
    } else {/*from   w ww.  j  a v  a2s  .  co m*/
        throw new IllegalStateException();
    }
}