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

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

Introduction

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

Prototype

public static DateTimeFormatter localTimeParser() 

Source Link

Document

Returns a generic ISO time parser for parsing local times.

Usage

From source file:org.apache.tamaya.jodatime.LocalTimeConverter.java

License:Apache License

@Override
public LocalTime convert(String value, ConversionContext context) {
    context.addSupportedFormats(LocalTimeConverter.class, PARSER_FORMATS);

    String trimmed = Objects.requireNonNull(value).trim();
    try {/*from   w w  w.  ja va 2  s  . c o  m*/
        return ISODateTimeFormat.localTimeParser().parseLocalTime(trimmed);
    } catch (RuntimeException e) {
        // Ok, go on and try the next parser
    }
    return null;
}

From source file:org.efaps.admin.datamodel.attributetype.TimeType.java

License:Apache License

/**
 * The value that can be set is a Date, a DateTime or a String
 * yyyy-MM-dd'T'HH:mm:ss.SSSZZ. It will be normalized to ISO Calender with
 * TimeZone from SystemAttribute Admin_Common_DataBaseTimeZone. In case that
 * the SystemAttribute is missing UTC will be used.
 * For storing the value in the database the time is set to 00:00;
 *
 * @param _value value to evaluate//from  w w w.  j av a2 s .c  o  m
 * @return evaluated value
 * @throws EFapsException on error
 */
@Override
protected Timestamp eval(final Object[] _value) throws EFapsException {
    final Timestamp ret;
    if ((_value == null) || (_value.length == 0) || (_value[0] == null)) {
        ret = null;
    } else {
        LocalTime time = new LocalTime();
        if (_value[0] instanceof Date) {
            time = new DateTime(_value[0]).toLocalTime();
        } else if (_value[0] instanceof DateTime) {
            time = ((DateTime) _value[0]).toLocalTime();
        } else if (_value[0] instanceof String) {
            time = ISODateTimeFormat.localTimeParser().parseLocalTime((String) _value[0]);
        }
        ret = new Timestamp(time.toDateTimeToday().getMillis());
    }
    return ret;
}