All Downloads are FREE. Search and download functionalities are using the official Maven repository.

grails.plugin.json.converters.LocalDateTimeJsonConverter.groovy Maven / Gradle / Ivy

Go to download

Provides additional view technologies to the Grails framework, including JSON and Markup views.

The newest version!
package grails.plugin.json.converters

import grails.plugin.json.builder.JsonGenerator
import groovy.transform.CompileStatic

import java.time.LocalDateTime
import java.time.format.DateTimeFormatter

/**
 * A class to render a {@link LocalDateTime} as json
 *
 * @author James Kleeh
 */
@CompileStatic
class LocalDateTimeJsonConverter implements JsonGenerator.Converter {

    @Override
    boolean handles(Class type) {
        LocalDateTime == type
    }

    @Override
    Object convert(Object value, String key) {
        DateTimeFormatter.ISO_LOCAL_DATE_TIME.format((LocalDateTime)value)
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy