List of usage examples for javax.xml.bind DatatypeConverter parseTime
public static java.util.Calendar parseTime(String lexicalXSDTime)
Converts the string argument into a Calendar value.
From source file:com.fluidops.iwb.api.ValueResolver.java
/** * Resolves a value string using a specified resolver (as string). * Can be extended on demand by new resolvers. Should not return * null.// w w w. ja va 2 s.co m * * @param value * @param resolver * @return */ public static String resolve(Value value, ResolverType resolver) { if (resolver == null) resolver = ResolverType.DEFAULT; if (value == null) value = ValueFactoryImpl.getInstance().createLiteral(""); try { switch (resolver) { case MS_TIMESTAMP2DATE: return resolveDateFromTimestamp(value.stringValue(), 1); case S_TIMESTAMP2DATE: return resolveDateFromTimestamp(value.stringValue(), 1000); case DATE: return resolveCalendar(DatatypeConverter.parseDate(value.stringValue()), "MMM dd, yyyy"); case TIME: return resolveCalendar(DatatypeConverter.parseTime(value.stringValue()), "HH:mm:ss"); case DATETIME: return resolveCalendar(DatatypeConverter.parseDateTime(value.stringValue()), "MMM dd, yyyy HH:mm:ss"); case SYSDATE: return resolveSysDate(value.stringValue()); case IMAGE: return resolveImage(value); case THUMBNAIL: return resolveThumbnail(value, "20px"); case BIGTHUMBNAIL: return resolveThumbnail(value, "50px"); case DOUBLE2INT: return resolveDecimalFromDouble(Double.valueOf(value.stringValue())); case URL: return resolveURL(value.stringValue(), null); case HTML: return resolveHtml(value); case LOGINLINK: return resolveURL(value.stringValue(), "Login"); case BYTE2KB: return resolveByte2X(value.stringValue(), "KB"); case BYTE2MB: return resolveByte2X(value.stringValue(), "MB"); case BYTE2GB: return resolveByte2X(value.stringValue(), "GB"); case BYTE2TB: return resolveByte2X(value.stringValue(), "TB"); case KBYTE2MB: return resolveKByte2X(value.stringValue(), "MB"); case KBYTE2GB: return resolveKByte2X(value.stringValue(), "GB"); case KBYTE2TB: return resolveKByte2X(value.stringValue(), "TB"); case PERCENT: return resolvePercent(value.stringValue()); case PERCENT_NOCONVERT: return resolvePercentNoConvert(value.stringValue()); case ROUND_DOUBLE: return resolveNumber2Places(value.stringValue()); case CURRENCY_USD: return resolveCurrency(value.stringValue(), "USD"); case CURRENCY_EUR: return resolveCurrency(value.stringValue(), "EUR"); case CURRENCY_CNY: return resolveCurrency(value.stringValue(), "CNY"); case DEFAULT_NOERROR: return resolveDefaultNoError(value); case DEFAULT: default: return resolveDefault(value); } } catch (Exception e) { return resolveDefault(value); } }
From source file:microsoft.exchange.webservices.data.property.complex.TimeChange.java
/** * Tries to read element from XML./*www . java 2 s . c o m*/ * * @param reader accepts EwsServiceXmlReader * @return True if element was read * @throws Exception throws Exception */ @Override public boolean tryReadElementFromXml(EwsServiceXmlReader reader) throws Exception { if (reader.getLocalName().equalsIgnoreCase(XmlElementNames.Offset)) { this.offset = EwsUtilities.getXSDurationToTimeSpan(reader.readElementValue()); return true; } else if (reader.getLocalName().equalsIgnoreCase(XmlElementNames.RelativeYearlyRecurrence)) { this.recurrence = new TimeChangeRecurrence(); this.recurrence.loadFromXml(reader, reader.getLocalName()); return true; } else if (reader.getLocalName().equalsIgnoreCase(XmlElementNames.AbsoluteDate)) { Calendar cal = DatatypeConverter.parseDate(reader.readElementValue()); cal.setTimeZone(TimeZone.getTimeZone("UTC")); this.absoluteDate = cal.getTime(); return true; } else if (reader.getLocalName().equalsIgnoreCase(XmlElementNames.Time)) { Calendar cal = DatatypeConverter.parseTime(reader.readElementValue()); this.time = new Time(cal.getTime()); return true; } else { return false; } }
From source file:com.bluexml.xforms.controller.mapping.MappingToolCommon.java
/** * Gets the date time from date and time. * // ww w. j a va2 s. c om * @param date * the date * @param time * the time * @return the date time from date and time */ protected String getDateTimeFromDateAndTime(String date, String time) { DateTime rdate = new DateTime(DatatypeConverter.parseDate(date)); DateTime rtime = new DateTime(DatatypeConverter.parseTime(time)); long millis = rdate.getMillis() - rdate.getMillisOfDay() + rtime.getMillisOfDay(); return DateTimeConverter.convert_XFormsToAlfresco_DateTime(millis); }