Example usage for com.fasterxml.jackson.databind.util ISO8601DateFormat ISO8601DateFormat

List of usage examples for com.fasterxml.jackson.databind.util ISO8601DateFormat ISO8601DateFormat

Introduction

In this page you can find the example usage for com.fasterxml.jackson.databind.util ISO8601DateFormat ISO8601DateFormat.

Prototype

public ISO8601DateFormat() 

Source Link

Usage

From source file:com.github.tomakehurst.wiremock.common.Dates.java

public static Date parse(String dateString) {
    try {/*from   w w  w.ja  v a2  s  . co  m*/
        return new ISO8601DateFormat().parse(dateString);
    } catch (ParseException e) {
        return throwUnchecked(e, Date.class);
    }
}

From source file:com.github.tomakehurst.wiremock.admin.Conversions.java

public static Date toDate(QueryParameter parameter) {
    try {/* w ww  .ja va2  s . c o m*/
        return parameter.isPresent() ? new ISO8601DateFormat().parse(parameter.firstValue()) : null;
    } catch (ParseException e) {
        throw new IllegalArgumentException(parameter.firstValue() + " is not a valid ISO8601 date");
    }
}

From source file:org.envirocar.wps.util.BasicStats.java

/**
 * calculates acceleration (delta_speed/delta_time in m/s^2) between two single
 * track measurements, represented as Geotools simple features
 * //from w w w.j a v  a 2s .c o  m
 * 
 * @param feat1
 *            first track measurement (must be temporally before second)
 * @param feat2
 *            second track measurement
 * @return acceleration between first and second measurement
 * @throws ParseException 
 */
public static double calculateAcceleration(SimpleFeature feat1, SimpleFeature feat2) throws ParseException {
    double acceleration = 0;

    //compute delta t in seconds
    ISO8601DateFormat df = new ISO8601DateFormat();
    Date timeStart = df.parse((String) feat1.getAttribute(FeatureProperties.TIME));
    Date timeEnd = df.parse((String) feat2.getAttribute(FeatureProperties.TIME));
    long delta_t = (timeEnd.getTime() - timeStart.getTime()) * 1000;

    //compute delta speed in m/s
    double delta_speed = 0;
    Object spo1 = feat1.getAttribute(FeatureProperties.SPEED);
    Object spo2 = feat2.getAttribute(FeatureProperties.SPEED);

    //compute delta speed in km/h
    if (spo1 != null && spo2 != null) {
        double speed1 = Double.parseDouble((String) spo1);
        double speed2 = Double.parseDouble((String) spo2);
        if (speed2 > speed1) {
            delta_speed = speed2 - speed1;
        }
    }

    //convert to m/s
    delta_speed = delta_speed * 0.278;

    //compute acceleration in m/s^2
    acceleration = delta_speed / delta_t;

    return acceleration;
}

From source file:io.soabase.core.rest.SoaApis.java

@GET
@Produces(MediaType.APPLICATION_JSON)/*from   w w w .  ja v a 2  s.  com*/
public Info getInfo() {
    TimeZone tz = TimeZone.getTimeZone("UTC");
    ISO8601DateFormat df = new ISO8601DateFormat();
    df.setTimeZone(tz);
    String now = df.format(new Date());
    String start = df.format(new Date(soaInfo.getStartTimeMs()));
    return new Info(soaInfo.getScopes(), soaInfo.getMainPort(), soaInfo.getAdminPort(),
            soaInfo.getServiceName(), soaInfo.getInstanceName(), start, now);
}

From source file:com.galenframework.storage.controllers.JsonTransformer.java

private JsonTransformer() {
    objectMapper = new ObjectMapper();
    //objectMapper.setDateFormat(new ISO8601DateFormat());
    objectMapper.setDateFormat(new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"));
    objectMapper.getSerializationConfig().with(new ISO8601DateFormat());
}

From source file:com.netflix.genie.common.util.JsonDateDeserializer.java

/**
 * {@inheritDoc}/*from w ww  .  jav a2 s. c  o m*/
 */
@Override
public Date deserialize(final JsonParser parser, final DeserializationContext context) throws IOException {
    final DateFormat format = new ISO8601DateFormat();

    final String text = parser.getText();

    if (StringUtils.isBlank(text)) {
        return null;
    }

    try {
        return format.parse(text);
    } catch (final ParseException pe) {
        throw new IOException(pe);
    }
}

From source file:io.soabase.core.SoaInfo.java

public static DateFormat newUtcFormatter() {
    TimeZone tz = TimeZone.getTimeZone("UTC");
    ISO8601DateFormat df = new ISO8601DateFormat();
    df.setTimeZone(tz);/*from w  ww.  j av  a2s.  c  o  m*/
    return df;
}

From source file:io.instacount.client.jackson.InstacountClientObjectMapper.java

/**
 * No-args Constructor.//  w  ww  . j ava2s.  co  m
 * 
 * @see "https://github.com/FasterXML/jackson-datatype-joda"
 */
public InstacountClientObjectMapper() {
    registerModule(new HttpUrlModule());
    registerModule(new JodaModule());
    registerModule(new GuavaModule());
    configure(SerializationFeature.WRITE_DATES_AS_TIMESTAMPS, false);
    configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
    setDateFormat(new ISO8601DateFormat());
}

From source file:io.getlime.push.configuration.WebApplicationConfig.java

/**
 * Custom object mapper to make sure that dates and other values serialize
 * correctly./*from  w w  w  .  j  a  va 2  s. co  m*/
 *
 * @return A new object mapper.
 */
private ObjectMapper objectMapper() {
    Jackson2ObjectMapperFactoryBean bean = new Jackson2ObjectMapperFactoryBean();
    bean.setIndentOutput(true);
    bean.setDateFormat(new ISO8601DateFormat());
    bean.afterPropertiesSet();
    ObjectMapper objectMapper = bean.getObject();
    objectMapper.registerModule(new JodaModule());
    return objectMapper;
}