List of usage examples for org.joda.time.format ISODateTimeFormat timeParser
public static DateTimeFormatter timeParser()
From source file:divconq.util.TimeUtil.java
License:Open Source License
/** * parse just the time// www.java 2 s . com * * @param t string with iso formatted time * @return time if parsed, or null */ static public LocalTime parseLocalTime(String t) { if (StringUtil.isEmpty(t)) return null; try { return ISODateTimeFormat.timeParser().parseDateTime(t).toLocalTime(); } catch (Exception x) { } return null; }
From source file:fr.inria.wimmics.prissma.selection.entities.ContextUnit.java
License:Open Source License
/** * Retrieves the specified property value from the context unit. * Used by GEO and TIME context units./*from www . ja v a 2 s .co m*/ * @param prop * @return * @throws ContextUnitException */ public double getComplexCtxUnitProp(Property prop) throws ContextUnitException { if (!instance.isResource()) throw new ContextUnitException(); if (this.type != CtxUnitType.GEO && this.type != CtxUnitType.TIME && instance.isResource()) throw new ContextUnitException(); else { Statement stat = ((Resource) instance).getProperty(prop); if (stat == null) throw new ContextUnitException(); // TIME conversions if (prop.equals(PrissmaProperties.pStart)) { String timeStr = stat.getLiteral().getString(); DateTimeFormatter dtf = ISODateTimeFormat.timeParser(); DateTime startTime = dtf.withZone(DateTimeZone.UTC).parseDateTime(timeStr); // UTC by default long millis = startTime.getMillis(); long seconds = millis / 1000; return seconds; } else if (prop.equals(PrissmaProperties.pDuration)) { String durationStr = stat.getLiteral().getString(); PeriodFormatter pf = ISOPeriodFormat.standard(); Period period = pf.parsePeriod(durationStr); int seconds = period.toStandardSeconds().getSeconds(); return seconds; } return stat.getLiteral().getDouble(); } }
From source file:org.fuin.objects4j.common.LocalTimeAdapter.java
License:Open Source License
@Override public final LocalTime unmarshal(final String str) { if (str == null) { return null; }/* w ww. j av a 2s . c om*/ return LocalTime.parse(str, ISODateTimeFormat.timeParser()); }
From source file:org.fuin.objects4j.common.LocalTimeAdapter.java
License:Open Source License
@Override public final LocalTime convertToEntityAttribute(final String str) { if (str == null) { return null; }//from ww w. j av a2 s . com return LocalTime.parse(str, ISODateTimeFormat.timeParser()); }