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

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

Introduction

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

Prototype

public ReadableInstantPrinter(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   ww w.  ja v a 2s. co m
        throw new IllegalStateException();
    }
}