List of usage examples for org.joda.time DateTime parse
public static DateTime parse(String str, DateTimeFormatter formatter)
From source file:com.linkedin.cubert.utils.DateTimeUtilities.java
License:Open Source License
public static DateTime getDateTime(String ts) { DateTimeFormatter formatter = DateTimeFormat.forPattern("yyyyMMdd"); DateTime result = DateTime.parse(ts, formatter); return result; }
From source file:com.linkedin.cubert.utils.DateTimeUtilities.java
License:Open Source License
public static DateTime getDateTime(String ts, String formatStr) { DateTimeFormatter formatter = DateTimeFormat.forPattern(formatStr); DateTime result = DateTime.parse(ts, formatter); return result; }
From source file:com.linkedin.pinot.core.segment.creator.impl.SegmentIndexCreationDriverImpl.java
License:Apache License
private long convertSDFToMillis(final String colValue) { final String sdfFormatStr = config.getSimpleDateFormat(); DateTimeFormatter sdfFormatter = DateTimeFormat.forPattern(sdfFormatStr); DateTime dateTime = DateTime.parse(colValue, sdfFormatter); return dateTime.getMillis(); }
From source file:com.microsoft.azure.credentials.AzureCliToken.java
License:Open Source License
Date expiresOn() { if (expiresOnDate == null) { try {//from ww w . j a va 2 s. c o m expiresOnDate = DateTime.parse(expiresOn, DateTimeFormat.forPattern("yyyy-MM-dd HH:mm:ss.SSSSSS")) .toDate(); } catch (IllegalArgumentException e) { expiresOnDate = DateTime.parse(expiresOn).toDate(); } } return expiresOnDate; }
From source file:com.microsoft.rest.DateTimeRfc1123.java
License:Open Source License
/** * Creates a new DateTimeRfc1123 object with the specified DateTime. * @param formattedString The datetime string in RFC1123 format *//*w ww.ja v a2 s .c o m*/ public DateTimeRfc1123(String formattedString) { this.dateTime = DateTime.parse(formattedString, RFC1123_DATE_TIME_FORMATTER); }
From source file:com.mycollab.common.service.impl.TimelineTrackingServiceImpl.java
License:Open Source License
@Override public Map<String, List<GroupItem>> findTimelineItems(String fieldGroup, List<String> groupVals, Date start, Date end, TimelineTrackingSearchCriteria criteria) { try {//from w w w . ja v a 2s. c o m DateTime startDate = new DateTime(start); final DateTime endDate = new DateTime(end); if (startDate.isAfter(endDate)) { throw new UserInvalidInputException("Start date must be greaterThan than end date"); } List<Date> dates = boundDays(startDate, endDate.minusDays(1)); Map<String, List<GroupItem>> items = new HashMap<>(); criteria.setFieldgroup(StringSearchField.and(fieldGroup)); List<GroupItem> cacheTimelineItems = timelineTrackingCachingMapperExt.findTimelineItems(groupVals, dates, criteria); DateTime calculatedDate = startDate.toDateTime(); if (cacheTimelineItems.size() > 0) { GroupItem item = cacheTimelineItems.get(cacheTimelineItems.size() - 1); String dateValue = item.getGroupname(); calculatedDate = DateTime.parse(dateValue, DateTimeFormat.forPattern("yyyy-MM-dd")); for (GroupItem map : cacheTimelineItems) { String groupVal = map.getGroupid(); Object obj = items.get(groupVal); if (obj == null) { List<GroupItem> itemLst = new ArrayList<>(); itemLst.add(map); items.put(groupVal, itemLst); } else { List<GroupItem> itemLst = (List<GroupItem>) obj; itemLst.add(map); } } } dates = boundDays(calculatedDate.plusDays(1), endDate); if (dates.size() > 0) { boolean isValidForBatchSave = true; final Set<String> types = criteria.getTypes().getValues(); SetSearchField<Integer> extraTypeIds = criteria.getExtraTypeIds(); Integer tmpExtraTypeId = null; if (extraTypeIds != null) { if (extraTypeIds.getValues().size() == 1) { tmpExtraTypeId = extraTypeIds.getValues().iterator().next(); } else { isValidForBatchSave = false; } } final Integer extraTypeId = tmpExtraTypeId; final List<Map> timelineItems = timelineTrackingMapperExt.findTimelineItems(groupVals, dates, criteria); if (isValidForBatchSave) { final Integer sAccountId = (Integer) criteria.getSaccountid().getValue(); final String itemFieldGroup = criteria.getFieldgroup().getValue(); JdbcTemplate jdbcTemplate = new JdbcTemplate(dataSource); final DateTimeFormatter formatter = DateTimeFormat.forPattern("yyyy-MM-dd"); final List<Map> filterCollections = new ArrayList<>( Collections2.filter(timelineItems, input -> { String dateStr = (String) input.get("groupname"); DateTime dt = formatter.parseDateTime(dateStr); return !dt.equals(endDate); })); jdbcTemplate.batchUpdate( "INSERT INTO `s_timeline_tracking_cache`(type, fieldval,extratypeid,sAccountId," + "forDay, fieldgroup,count) VALUES(?,?,?,?,?,?,?)", new BatchPreparedStatementSetter() { @Override public void setValues(PreparedStatement preparedStatement, int i) throws SQLException { Map item = filterCollections.get(i); // preparedStatement.setString(1, types); String fieldVal = (String) item.get("groupid"); preparedStatement.setString(2, fieldVal); preparedStatement.setInt(3, extraTypeId); preparedStatement.setInt(4, sAccountId); String dateStr = (String) item.get("groupname"); DateTime dt = formatter.parseDateTime(dateStr); preparedStatement.setDate(5, new java.sql.Date(dt.toDate().getTime())); preparedStatement.setString(6, itemFieldGroup); int value = ((BigDecimal) item.get("value")).intValue(); preparedStatement.setInt(7, value); } @Override public int getBatchSize() { return filterCollections.size(); } }); } for (Map map : timelineItems) { String groupVal = (String) map.get("groupid"); GroupItem item = new GroupItem(); item.setValue(((BigDecimal) map.get("value")).doubleValue()); item.setGroupid((String) map.get("groupid")); item.setGroupname((String) map.get("groupname")); Object obj = items.get(groupVal); if (obj == null) { List<GroupItem> itemLst = new ArrayList<>(); itemLst.add(item); items.put(groupVal, itemLst); } else { List<GroupItem> itemLst = (List<GroupItem>) obj; itemLst.add(item); } } } return items; } catch (Exception e) { LOG.error("Error", e); return null; } }
From source file:com.mycompany.assignment1.Programme.java
public Programme(String name, String SD, String ED) { Name = name;/*w ww . j ava2 s.co m*/ startdate = DateTime.parse(SD, DateTimeFormat.forPattern("dd/MM/yyyy")); enddate = DateTime.parse(ED, DateTimeFormat.forPattern("dd/MM/yyyy")); }
From source file:com.nestedbird.components.bridges.JodaDateTimeSplitBridge.java
License:Open Source License
@Override public Object get(final String name, final Document document) { final IndexableField stringDateTime = document.getField(name); if (stringDateTime != null) { return DateTime.parse(stringDateTime.stringValue(), DateTimeFormat.forPattern(DATETIME_FORMAT)); } else {//from ww w . java 2 s.co m return null; } }
From source file:com.nestedbird.modules.formparser.FormParse.java
License:Open Source License
/** * Parse JODA DateTime/*from w w w . ja va 2 s.co m*/ * * @param value joda datetime value * @return new Joda DateTime */ private DateTime parseDateTime(final Object value) { return DateTime.parse(value.toString(), DateTimeFormat.forPattern("yyyy-MM-dd HH:mm:ss")); }
From source file:com.netflix.raigad.indexmanagement.indexfilters.DailyIndexNameFilter.java
License:Apache License
@Override public boolean filter(String name) { if (name.length() < 9) { return false; }//from w w w .ja v a2s . c o m String date = name.substring(name.length() - 8, name.length()); try { DateTime.parse(date, DateTimeFormat.forPattern("YYYYMMdd")); return true; } catch (Exception e) { return false; } }