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

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

Introduction

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

Prototype

public static DateTimeFormatter dateTimeNoMillis() 

Source Link

Document

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

Usage

From source file:com.spotify.reaper.resources.view.RepairRunStatus.java

License:Apache License

@JsonProperty("creation_time")
public void setCreationTimeISO8601(String dateStr) {
    if (null != dateStr) {
        creationTime = ISODateTimeFormat.dateTimeNoMillis().parseDateTime(dateStr);
    }//from w  w w  .jav  a 2s .  c o  m
}

From source file:com.spotify.reaper.resources.view.RepairRunStatus.java

License:Apache License

@JsonProperty("start_time")
public void setStartTimeISO8601(String dateStr) {
    if (null != dateStr) {
        startTime = ISODateTimeFormat.dateTimeNoMillis().parseDateTime(dateStr);
    }//from  w w w.ja  va2s . c o  m
}

From source file:com.spotify.reaper.resources.view.RepairRunStatus.java

License:Apache License

@JsonProperty("end_time")
public void setEndTimeISO8601(String dateStr) {
    if (null != dateStr) {
        endTime = ISODateTimeFormat.dateTimeNoMillis().parseDateTime(dateStr);
    }/* ww w . j  a  v  a 2 s .  com*/
}

From source file:com.spotify.reaper.resources.view.RepairRunStatus.java

License:Apache License

@JsonProperty("pause_time")
public void setPauseTimeISO8601(String dateStr) {
    if (null != dateStr) {
        pauseTime = ISODateTimeFormat.dateTimeNoMillis().parseDateTime(dateStr);
    }/*from w  w  w  .j a  v  a 2s  .  c  o m*/
}

From source file:com.spotify.reaper.resources.view.RepairRunStatus.java

License:Apache License

@JsonProperty("estimated_time_of_arrival")
public void setEstimatedTimeOfArrivalISO8601(String dateStr) {
    if (null != dateStr) {
        estimatedTimeOfArrival = ISODateTimeFormat.dateTimeNoMillis().parseDateTime(dateStr);
    }/*from   w ww  .  j  ava  2 s  . com*/
}

From source file:com.spotify.reaper.resources.view.RepairScheduleStatus.java

License:Apache License

@JsonProperty("next_activation")
public void setNextActivationISO8601(String dateStr) {
    if (null != dateStr) {
        nextActivation = ISODateTimeFormat.dateTimeNoMillis().parseDateTime(dateStr);
    }//from   w w  w  . ja v  a2 s. com
}

From source file:com.thoughtworks.studios.shine.cruise.GoDateTime.java

License:Apache License

public static DateTime parseToUTC(String timestampString) throws GoDateTimeException {

    DateTimeFormatter format = ISODateTimeFormat.dateTimeNoMillis();
    DateTime dateTime;//from w  w w.j av  a 2 s .c  o  m
    try {
        dateTime = format.parseDateTime(timestampString);
    } catch (java.lang.IllegalArgumentException e) {
        // sigh. handle old cruise timestamp format, e.g. 2008-09-19 02:18:39 +0800
        format = DateTimeFormat.forPattern("yyyy-MM-dd HH:mm:ss Z");
        try {
            dateTime = format.parseDateTime(timestampString);
        } catch (java.lang.IllegalArgumentException e2) {
            // give up !!
            throw new GoDateTimeException("Could not parse datetime " + timestampString, e2);
        }
    }
    return dateTime.toDateTime(DateTimeZone.forID("UTC"));
}

From source file:com.tkmtwo.sarapi.ArsDataType.java

License:Apache License

public static String getArString(Value v) {
    if (isNull(v)) {
        return null;
    }/*  ww  w.j  a  v  a2  s.c  o m*/
    ArsDataType adt = valueOfDataType(v.getDataType());
    if (adt == null) {
        throw new IllegalArgumentException("DataType of Value not known.");
    }

    String s = null;
    switch (adt) {
    case NULL:
        s = null;
        break;
    case INTEGER:
        s = ((Integer) v.getValue()).toString();
        break;
    case REAL:
        s = ((Double) v.getValue()).toString();
        break;
    case CHAR:
        s = ((String) v.getValue());
        break;
    case ENUM:
        s = ((Integer) v.getValue()).toString();
        break;
    case TIME:
        DateTime timestampDt = new DateTime(((Timestamp) v.getValue()).getValue() * 1000L);
        s = ISODateTimeFormat.dateTimeNoMillis().print(timestampDt);
        break;
    case DECIMAL:
        s = ((BigDecimal) v.getValue()).toString();
        break;
    case CURRENCY:
        CurrencyValue cv = (CurrencyValue) v.getValue();
        s = cv.getValue().toString() + " " + cv.getCurrencyCode();
        break;
    case DATE:
        DateTime dateInfoDt = new DateTime(((DateInfo) v.getValue()).GetDate());
        s = ISODateTimeFormat.date().print(dateInfoDt);
        break;
    case TIME_OF_DAY:
        DateTime timeDt = LocalTime.fromMillisOfDay(((Time) v.getValue()).getValue() * 1000L)
                .toDateTimeToday(DateTimeZone.UTC);
        s = ISODateTimeFormat.timeNoMillis().print(timeDt);
        break;
    default:
        s = v.getValue().toString();
    }
    return s;
}

From source file:com.tkmtwo.timex.convert.IsoDateTimeConverter.java

License:Apache License

@Override
public DateTime convert(String s) {
    String ts = blankToNull(s);/*from ww  w  . j  a  v  a  2s.  c  om*/
    if (ts == null) {
        return null;
    }

    int tsLength = ts.length();

    if (tsLength >= 23 && DATE_TIME_SEPARATOR.matches(ts.charAt(10))) {

        //ISO Extended with millis yyyy-MM-ddTHH:mm:ss.SSSZ
        return ISODateTimeFormat.dateTime().parseDateTime(ensureTeeAndZee(ts, 10));

    } else if (tsLength >= 19 && DATE_TIME_SEPARATOR.matches(ts.charAt(10))) {

        //ISO Extended without millis yyyy-MM-ddTHH:mm:ssZ
        return ISODateTimeFormat.dateTimeNoMillis().parseDateTime(ensureTeeAndZee(ts, 10));

    } else if (tsLength >= 19 && DATE_TIME_SEPARATOR.matches(ts.charAt(8))) {

        //ISO Basic with millis yyyyMMddTHHmmss.SSSZ
        return ISODateTimeFormat.basicDateTime().parseDateTime(ensureTeeAndZee(ts, 8));

    } else if (tsLength >= 15 && DATE_TIME_SEPARATOR.matches(ts.charAt(8))) {

        //ISO Basic without millis yyyyMMddTHHmmssZ
        return ISODateTimeFormat.basicDateTimeNoMillis().parseDateTime(ensureTeeAndZee(ts, 8));

    } else if (ASCII_DIGITS.matchesAllOf(ts)) {

        return new DateTime(Long.parseLong(ts));

    }

    throw new IllegalArgumentException(
            String.format("Input string '%s' can not be converted to a DateTime.", s));
}

From source file:com.tkmtwo.timex.convert.IsoExtendedConverter.java

License:Apache License

@Override
public DateTime convert(String s) {
    checkArgument(!isNullOrEmpty(s), "DateTime string is empty.");
    return ISODateTimeFormat.dateTimeNoMillis().parseDateTime(s);
}