List of usage examples for org.joda.time.format ISODateTimeFormat dateTimeParser
public static DateTimeFormatter dateTimeParser()
From source file:org.jtalks.tests.jcommune.mail.mailtrap.MailtrapMail.java
License:Open Source License
private List<Metadata> getMetadataList(MessageDto[] messageDtoArray) { List<Metadata> metadataList = new ArrayList<>(); Metadata metadata;//from ww w . j av a2 s . co m for (MessageDto messageDto : messageDtoArray) { Message message = messageDto.getMessage(); metadata = new Metadata(); metadata.setId(message.getId()); metadata.setTitle(message.getTitle()); metadata.setRecipient(message.getRecipients()[0].getRecipient().getTitle().replaceAll("[<>]", "")); metadata.setDateTime(ISODateTimeFormat.dateTimeParser().parseDateTime(message.getCreated_at())); metadataList.add(metadata); } return metadataList; }
From source file:org.kuali.rice.krad.service.util.DateTimeConverter.java
License:Educational Community License
@Override public Object fromString(String value) { return ISODateTimeFormat.dateTimeParser().parseDateTime(value); }
From source file:org.ldp4j.application.sdk.internal.DateObjectFactory.java
License:Apache License
@Override public Date fromString(String rawValue) { try {/*from www.j av a 2s . c om*/ return ISODateTimeFormat.dateTimeParser().parseDateTime(rawValue).toDate(); } catch (Exception e) { throw new ObjectParseException(e, Date.class, rawValue); } }
From source file:org.ldp4j.application.sdk.internal.DateTimeObjectFactory.java
License:Apache License
@Override public DateTime fromString(String rawValue) { try {/*w w w . ja va2 s .c om*/ return ISODateTimeFormat.dateTimeParser().parseDateTime(rawValue); } catch (Exception e) { throw new ObjectParseException(e, DateTime.class, rawValue); } }
From source file:org.ldp4j.application.sdk.internal.SqlDateObjectFactory.java
License:Apache License
@Override public Date fromString(String rawValue) { try {//w w w.ja v a2 s . c o m return TimeUtils.newInstance().from(ISODateTimeFormat.dateTimeParser().parseDateTime(rawValue)) .toSqlDate(); } catch (Exception e) { throw new ObjectParseException(e, Date.class, rawValue); } }
From source file:org.ldp4j.application.sdk.internal.XMLGregorianCalendarObjectFactory.java
License:Apache License
@Override public XMLGregorianCalendar fromString(String rawValue) { try {/*from w ww. j a va 2s. co m*/ return TimeUtils.newInstance().from(ISODateTimeFormat.dateTimeParser().parseDateTime(rawValue)) .toXMLGregorianCalendar(); } catch (Exception e) { throw new ObjectParseException(e, XMLGregorianCalendar.class, rawValue); } }
From source file:org.mule.modules.utils.date.DateConventions.java
License:Open Source License
/** * The Mule date format. By convention, dates are expressed in ISO date time. For * example, the following date strings are accepted: * <ul>/*from w ww . jav a 2 s . c om*/ * <li>2012-01-09T12:18:14Z</li> * <li>2012-01-09T12:18:14-02:00</li> * <li>2012-01-09T12:18:14</li> * <li>2012-01-09</li> * </ul> * * @return A {@link DateTimeFormatter} with mule date format. */ public static DateTimeFormatter defaultDateTimeFormat() { return ISODateTimeFormat.dateTimeParser(); }
From source file:org.nuxeo.ecm.platform.oauth2.openid.auth.facebook.FacebookUserInfo.java
License:Apache License
@Override public Date getUpdatedTime() { Date date;/*from www.j a va2 s. c om*/ try { DateTimeFormatter parser = ISODateTimeFormat.dateTimeParser(); DateTime dateTime = parser.parseDateTime(updatedTime); date = dateTime.toDate(); } catch (IllegalArgumentException e) { return null; } return date; }
From source file:org.nuxeo.ecm.platform.sync.processor.TupleProcessorAddDocument.java
License:Open Source License
@Override public void process() throws ClientException { if (!session.exists(new PathRef(parentPath))) { log.warn("Parent path " + parentPath + " doesn't exist => Document " + tuple.getClientId() + " will not be created"); return;//from w ww . j a v a 2s . co m } log.debug("Starting the process of adding live document " + tuple.getClientId() + " on the client side: " + name); // a normal document model will be created localDocument = new DocumentModelImpl((String) null, tuple.getType(), tuple.getClientId(), new Path(name), null, null, new PathRef(parentPath), null, null, null, session.getRepositoryName()); propertyValue = ImportUtils.getContextDataInfo(contextData, CoreSession.IMPORT_LOCK_OWNER); if (propertyValue != null) { localDocument.putContextData(CoreSession.IMPORT_LOCK_OWNER, propertyValue); String createdString = ImportUtils.getContextDataInfo(contextData, CoreSession.IMPORT_LOCK_CREATED); localDocument.putContextData(CoreSession.IMPORT_LOCK_CREATED, ISODateTimeFormat.dateTimeParser().parseDateTime(createdString).toGregorianCalendar()); } propertyValue = ImportUtils.getContextDataInfo(contextData, CoreSession.IMPORT_CHECKED_IN); if (propertyValue != null) { localDocument.putContextData(CoreSession.IMPORT_CHECKED_IN, new Boolean(propertyValue)); } propertyValue = ImportUtils.getContextDataInfo(contextData, CoreSession.IMPORT_BASE_VERSION_ID); if (propertyValue != null) { localDocument.putContextData(CoreSession.IMPORT_BASE_VERSION_ID, propertyValue); } propertyValue = ImportUtils.getContextDataInfo(contextData, CoreSession.IMPORT_VERSION_MAJOR); if (propertyValue != null) { localDocument.putContextData(CoreSession.IMPORT_VERSION_MAJOR, Long.valueOf(propertyValue)); } propertyValue = ImportUtils.getContextDataInfo(contextData, CoreSession.IMPORT_VERSION_MINOR); if (propertyValue != null) { localDocument.putContextData(CoreSession.IMPORT_VERSION_MINOR, Long.valueOf(propertyValue)); } localDocument.setPathInfo(parentPath, name); setProperties(); runUnrestrictedImport(); setACE(); updateDocument(); log.debug("Finishing the process of adding live document " + tuple.getClientId() + " on the client side: " + name); }
From source file:org.ohmage.domain.campaign.prompt.TimestampPrompt.java
License:Apache License
/** * Validates that a given value is valid and, if so, converts it into an * appropriate object./*from w w w.j ava 2 s . co m*/ * * @param value The value to be validated. This must be one of the * following:<br /> * <ul> * <li>{@link NoResponse}</li> * <li>{@link Date}</li> * <li>{@link Calendar}</li> * <li>{@link String} that represents:</li> * <ul> * <li>{@link NoResponse}</li> * <li>ISO 8601 formatted date with or without the time. * </li> * <ul> * </ul> * * @return A Date object or a {@link NoResponse} object. * * @throws DomainException The value is invalid. */ @Override public Object validateValue(final Object value) throws DomainException { // If it's already a NoResponse value, then return make sure that if it // was skipped that it as skippable. if (value instanceof NoResponse) { if (NoResponse.SKIPPED.equals(value) && (!skippable())) { throw new DomainException("The prompt, '" + getId() + "', was skipped, but it is not skippable."); } return value; } // If it's already a DateTime, return it. else if (value instanceof DateTime) { return value; } // If it's a Date, convert it to a DateTime and return it. else if (value instanceof Date) { return new DateTime(((Date) value).getTime()); } // If it's a Calendar, convert it to a DateTime and return it. else if (value instanceof Calendar) { Calendar calValue = (Calendar) value; return new DateTime(calValue.getTimeInMillis(), DateTimeZone.forTimeZone(calValue.getTimeZone())); } // If it's a String, attempt to convert it to a DateTime and return it. else if (value instanceof String) { try { return NoResponse.valueOf((String) value); } catch (IllegalArgumentException notNoResponse) { try { return DateTimeUtils.getDateTimeFromString((String) value); } catch (IllegalArgumentException notOurDateTime) { try { return ISODateTimeFormat.dateTimeParser().withOffsetParsed().parseDateTime((String) value); } catch (IllegalArgumentException notIsoDateTime) { throw new DomainException( "The string value could not be converted to a date for prompt '" + getId() + "'.", notIsoDateTime); } } } } throw new DomainException("The value could not be converted to a valid date for prompt '" + getId() + "'."); }