Example usage for org.joda.time.format ISODateTimeFormat dateTime

List of usage examples for org.joda.time.format ISODateTimeFormat dateTime

Introduction

In this page you can find the example usage for org.joda.time.format ISODateTimeFormat dateTime.

Prototype

public static DateTimeFormatter dateTime() 

Source Link

Document

Returns a formatter that combines a full date and time, separated by a 'T' (yyyy-MM-dd'T'HH:mm:ss.SSSZZ).

Usage

From source file:org.jadira.usertype.dateandtime.joda.columnmapper.StringColumnInstantMapper.java

License:Apache License

@Override
public String toNonNullValue(Instant value) {

    String formatted = ISODateTimeFormat.dateTime().print(value);
    if (formatted.endsWith(".000Z")) {
        formatted = formatted.substring(0, formatted.length() - 5) + "Z";
    }/*from   w  ww.  j  a v a2s  .c o m*/
    return formatted;
}

From source file:org.jboss.pressgang.ccms.filter.structures.FilterFieldDateTimeData.java

License:Open Source License

@Override
public void setData(final String value) {
    try {/*from w  w  w.j  av a 2 s.  c  o  m*/
        if (isNullOrEmpty(value)) {
            data = null;
        } else {
            data = new DateTime(ISODateTimeFormat.dateTime().parseDateTime(value));
        }
    } catch (final Exception ex) {
        log.debug("Malformed Filter query parameter for the \"{}\" parameter. Value = {}", name, value);
    }
}

From source file:org.jboss.pressgang.ccms.filter.structures.FilterFieldDateTimeData.java

License:Open Source License

@Override
public String getDataString() {
    return data == null ? null : ISODateTimeFormat.dateTime().print(data);
}

From source file:org.jboss.pressgang.ccms.rest.v1.query.base.RESTBaseQueryBuilderV1.java

License:Open Source License

protected void put(final String constant, final Object value) {
    /* If the constant and value is null do nothing */
    if (value == null && constant == null) {
        return;/*from w w w.j  a v  a2 s  . c  om*/
    }
    /* If the constant is set and value is null then remove the constant */
    else if (value == null) {
        filterVars.remove(constant);
    }

    /* Convert the value to a string */
    if (value instanceof String) {
        if (!((String) value).isEmpty()) {
            filterVars.put(constant, value.toString());
        }
    } else if (value instanceof DateTime) {
        filterVars.put(constant, ISODateTimeFormat.dateTime().print((DateTime) value));
    } else if (value instanceof Date) {
        filterVars.put(constant, ISODateTimeFormat.dateTime().print(new DateTime(value)));
    } else if (value instanceof Boolean) {
        if (((Boolean) value) == false) {
            filterVars.remove(constant);
        } else {
            filterVars.put(constant, value.toString());
        }
    } else {
        filterVars.put(constant, value.toString());
    }
}

From source file:org.jboss.pressgang.ccms.rest.v1.query.RESTTopicQueryBuilderV1.java

License:Open Source License

public DateTime getStartCreateDate() {
    final String startCreateDate = get(CommonFilterConstants.STARTDATE_FILTER_VAR);
    return startCreateDate == null ? null
            : new DateTime(ISODateTimeFormat.dateTime().parseDateTime(startCreateDate));
}

From source file:org.jboss.pressgang.ccms.rest.v1.query.RESTTopicQueryBuilderV1.java

License:Open Source License

public DateTime getEndCreateDate() {
    final String startCreateDate = get(CommonFilterConstants.ENDDATE_FILTER_VAR);
    return startCreateDate == null ? null
            : new DateTime(ISODateTimeFormat.dateTime().parseDateTime(startCreateDate));
}

From source file:org.jboss.pressgang.ccms.rest.v1.query.RESTTopicQueryBuilderV1.java

License:Open Source License

public DateTime getStartEditDate() {
    final String startEditDate = get(CommonFilterConstants.STARTEDITDATE_FILTER_VAR);
    return startEditDate == null ? null
            : new DateTime(ISODateTimeFormat.dateTime().parseDateTime(startEditDate));
}

From source file:org.jboss.pressgang.ccms.rest.v1.query.RESTTopicQueryBuilderV1.java

License:Open Source License

public DateTime getEndEditDate() {
    final String endEditDate = get(CommonFilterConstants.ENDEDITDATE_FILTER_VAR);
    return endEditDate == null ? null : new DateTime(ISODateTimeFormat.dateTime().parseDateTime(endEditDate));
}

From source file:org.jevis.commons.dataprocessing.v2.DataProcessing.java

License:Open Source License

public static <T> T GetOptionValue(JEVisOption parent, String key, Object defaultvalue) {
    try {//w w w.  ja v a  2  s.  c  om
        System.out.println("Gettring option value '" + key + "' from parent: " + parent.getKey()
                + " fallback value: '" + defaultvalue + "'");
        if (Options.hasOption(key, parent)) {
            System.out.println("option exist");
            String mString = Options.getFirstOption(key, parent).getValue();

            if (defaultvalue instanceof Double) {
                return (T) (Double) Double.parseDouble(mString);
            } else if (defaultvalue instanceof Integer) {
                return (T) (Integer) Integer.parseInt(mString);
            } else if (defaultvalue instanceof String) {
                return (T) mString;
            } else if (defaultvalue instanceof DateTime) {
                DateTime dateTime = DateTime.parse(mString, ISODateTimeFormat.dateTime());//yyyy-MM-dd'T'HH:mm:ss.SSSZZ
                return (T) dateTime;
            } else if (defaultvalue instanceof Boolean) {
                return (T) Boolean.valueOf(mString);
            } else {
                System.out.println("Unsupportet Class '" + defaultvalue.getClass() + "' returning String");
                return (T) mString;
            }

        } else {
            System.out.println("Paremeter not found returning default");
            return (T) defaultvalue;
        }
    } catch (Exception ex) {
        System.out.println("error return default: " + ex);
        return (T) defaultvalue;
    }
}

From source file:org.jevis.commons.json.JsonFactory.java

License:Open Source License

public static JsonAttribute buildAttribute(JEVisAttribute att, boolean allSamples) throws JEVisException {
    JsonAttribute json = new JsonAttribute();
    DateTimeFormatter fmt = ISODateTimeFormat.dateTime();

    json.setName(att.getName());//www .j a v  a 2  s .  com
    if (att.hasSample()) {
        json.setFirstTS(fmt.print(att.getTimestampFromFirstSample()));
        json.setLastTS(fmt.print(att.getTimestampFromLastSample()));
        json.setLastvalue(att.getLatestSample().getValueAsString());

        if (allSamples) {
            json.setSamples(new ArrayList<JsonSample>());

            for (JEVisSample samp : att.getAllSamples()) {
                json.getSamples().add(JsonFactory.buildSample(samp));
            }

        }

    }
    json.setSamplecount(att.getSampleCount());
    json.setPeriod("P15m");
    json.setObject(att.getObject().getID());

    return json;

}