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

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

Introduction

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

Prototype

public Date parse(String source) throws ParseException 

Source Link

Document

Parses text from the beginning of the given string to produce a date.

Usage

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 ww  w . j a va2 s  .  c om*/
 * 
 * @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:com.example.mego.adas.videos.api.YouTubeApiUtilities.java

/**
 * return a DataSend object to parse it to extract the time and date
 *///from  w w w  .ja  v a2 s.  c  o  m
public static Date fromISO8601(String publishedDate) {
    Date date = null;
    ISO8601DateFormat dateFormat = new ISO8601DateFormat();
    try {
        date = dateFormat.parse(publishedDate);
    } catch (ParseException e) {
        e.printStackTrace();
    }
    return date;
}