List of usage examples for org.joda.time DateTime parse
public static DateTime parse(String str, DateTimeFormatter formatter)
From source file:org.oxymores.chronix.wapi.ServiceClient.java
License:Apache License
@Override public List<Date> getNextRRuleOccurrences(DTORRule rule, String lowerBound, String higherBound) { ClockRRule r = DtoToCore.getRRule(rule); Clock tmp = new Clock(); tmp.addRRuleADD(r);/* ww w . ja va2 s . c o m*/ PeriodList pl = null; DateTimeFormatter df = DateTimeFormat.forPattern("dd/MM/yyyy HH:mm"); DateTime start = DateTime.parse(lowerBound, df); DateTime end = DateTime.parse(higherBound, df); try { pl = tmp.getOccurrences(start, end); } catch (ParseException e) { // TODO Auto-generated catch block e.printStackTrace(); } ArrayList<Date> res = new ArrayList<Date>(); for (Object pe : pl) { Period p = (Period) pe; res.add(p.getStart()); } return res; }
From source file:org.shadowmask.core.discovery.rules.DateRule.java
License:Apache License
@Override public boolean evaluate() { if (value == null) { throw new DataDiscoveryException("Should fill the column value before fire inspect rules."); }/*from w w w . j a v a 2s . c o m*/ DateTimeFormatter format; DateTime dateTime; for (String pattern : DateFormatPattern.patterns) { format = DateTimeFormat.forPattern(pattern); try { dateTime = DateTime.parse(value, format); } catch (Exception e) { continue; } if (dateTime != null) { return true; } } return false; }
From source file:org.shadowmask.core.discovery.rules.TimestampRule.java
License:Apache License
@Override public boolean evaluate() { if (value == null) { throw new DataDiscoveryException("Should fill the column value before fire inspect rules."); }/*from w w w . j a v a 2 s . com*/ DateTimeFormatter format; DateTime dateTime; for (String pattern : TimeFormatPattern.patterns) { format = DateTimeFormat.forPattern(pattern); try { dateTime = DateTime.parse(value, format); } catch (Exception e) { continue; } if (dateTime != null) { return true; } } return false; }
From source file:org.slc.sli.api.security.context.validator.AbstractContextValidator.java
License:Apache License
/** * Parse the String representing a DateTime and return the corresponding DateTime. * * @param convert/*from www.j a va 2s .c om*/ * String to be converted (of format yyyy-MM-dd). * @return DateTime object. */ protected DateTime getDateTime(String convert) { return DateTime.parse(convert, DateHelper.getDateTimeFormat()); }
From source file:org.slc.sli.bulk.extract.date.EntityDateHelper.java
License:Apache License
private static boolean isBeforeOrEqualDate(String begin, DateTime upToDate) { DateTime beginDate = (begin == null) ? DateTime.now().toDateMidnight().toDateTime() : DateTime.parse(begin, DateHelper.getDateTimeFormat()); return !beginDate.isAfter(upToDate.toDateMidnight().toDateTime()); }
From source file:org.slc.sli.common.util.datetime.DateHelper.java
License:Apache License
public boolean isFieldExpired(Map<String, Object> body, String fieldName, boolean useGracePeriod) { boolean expired = false; if (null != body.get(fieldName)) { DateTime expire = DateTime.parse((String) body.get(fieldName), FMT); DateTime now = DateTime.now();/* w w w . j a v a 2 s . c om*/ if (useGracePeriod) { int numDays = Integer.parseInt(gracePeriod); now = now.minusDays(numDays); } expired = now.isAfter(expire); } return expired; }
From source file:org.slc.sli.common.util.datetime.DateHelper.java
License:Apache License
/** * Get the date from the provided field/*from w ww . j av a 2 s.co m*/ * @param body entity body. * @param fieldName name of the date field. * @return */ public DateTime getDate(Map<String, Object> body, String fieldName) { DateTime date = null; if (body.get(fieldName) != null) { date = DateTime.parse((String) body.get(fieldName), FMT); } return date; }
From source file:org.supercsv.cellprocessor.joda.ParseDateTime.java
License:Apache License
/** * {@inheritDoc}/*from w w w . ja v a 2s. c o m*/ */ @Override protected DateTime parse(final String string, final DateTimeFormatter formatter) { return DateTime.parse(string, formatter); }
From source file:org.vaadin.addons.javaee.fields.converter.StringToDateTimeConverter.java
License:Apache License
@Override public DateTime convertToModel(String value, Class<? extends DateTime> targetType, Locale locale) throws Converter.ConversionException { if (value == null) { return null; }//from ww w. j av a2s.co m return DateTime.parse(value, DateTimeFormat.shortDate().withLocale(locale)); }
From source file:pl.nort.dayoneevernote.transformer.ExtractDateFromTitleTransformer.java
License:Apache License
@Override public Note apply(Note note) { Note.Builder builder = new Note.Builder().cloneOf(note); if (note.getTitle().matches(titlePattern)) { try {//w ww . ja va2s .c o m DateTime dt = DateTime.parse(note.getTitle(), DateTimeFormat.forPattern(datePattern).withZoneUTC()); builder.withCreationTime(dt); } catch (IllegalArgumentException e) { // NOP } } return builder.build(); }