List of usage examples for org.joda.time DateTime parse
@FromString public static DateTime parse(String str)
From source file:com.celtris.exparse.utils.Conversion.java
License:Apache License
public static DateTime convertDateTime(String value, DateTimeFormatter dateTimeFormatter) { if (dateTimeFormatter == null) { try {/*from w w w . j av a 2 s .c o m*/ return DateTime.parse(value); } catch (UnsupportedOperationException e) { throw new IllegalArgumentException(); } catch (IllegalArgumentException e) { throw new IllegalArgumentException(); } } else { try { return dateTimeFormatter.parseDateTime(value); } catch (UnsupportedOperationException e) { throw new IllegalArgumentException(); } catch (IllegalArgumentException e) { throw new IllegalArgumentException(); } } }
From source file:com.collective.celos.ScheduledTime.java
License:Apache License
public ScheduledTime(String formattedDate) { this(DateTime.parse(formattedDate)); }
From source file:com.dhr.security.LicenseValidation.java
License:Open Source License
Boolean isInvalidLicense(String encryptedLicenseKey, DateTime today) { if (UtilValidator.isEmpty(encryptedLicenseKey)) return invalidLicense; String currentMachineMacAddress; try {// w w w . ja va 2s . com currentMachineMacAddress = getMachineMacAddress(); } catch (Exception e) { return invalidLicense; } String decryptedLicenseKey = decryptLicenseKey(encryptedLicenseKey); final String[] key = decryptedLicenseKey.split("#"); if (key.length != 2) { return invalidLicense; } final String licenseKey = key[0]; final DateTime expiryDate = DateTime.parse(key[1]); if (currentMachineMacAddress.equalsIgnoreCase(licenseKey) && today.isBefore(expiryDate.getMillis())) return validLicense; return invalidLicense; }
From source file:com.duboisproject.rushhour.database.SdbInterface.java
License:Open Source License
protected static GameStatistics parseStats(Item item) { Map<String, String> attributes = mapify(item.getAttributes()); GameStatistics stats = new GameStatistics(); stats.levelId = Integer.parseInt(attributes.get(PLAYS_LEVEL)); stats.totalMoves = Integer.parseInt(attributes.get(PLAYS_TOTAL_MOVES)); stats.resetMoves = Integer.parseInt(attributes.get(PLAYS_RESET_MOVES)); stats.startTime = DateTime.parse(attributes.get(PLAYS_START)); stats.totalCompletionTime = Duration.parse(attributes.get(PLAYS_TOTAL_TIME)); stats.resetCompletionTime = Duration.parse(attributes.get(PLAYS_RESET_TIME)); return stats; }
From source file:com.enonic.cms.core.search.ElasticSearchIndexedFieldsTranslator.java
License:Open Source License
private void addIndexEntityField(ContentIndexFieldSet indexFieldSet, String name, Map<String, GetField> fields) { final GetField field; final String fieldPath = name.replace("_", "/"); if (fields.containsKey(name + INDEX_FIELD_TYPE_SEPARATOR + DATE_FIELD_POSTFIX)) { field = fields.get(name + INDEX_FIELD_TYPE_SEPARATOR + DATE_FIELD_POSTFIX); final DateTime dateTime = DateTime.parse((String) field.getValue()); indexFieldSet.addFieldWithDateValue(fieldPath, dateTime.toDate(), ""); } else {//from w ww . ja va2s. c o m field = fields.get(name); indexFieldSet.addFieldWithAnyValue(fieldPath, StringUtils.join(field.getValues(), ',')); } }
From source file:com.epam.ta.reportportal.core.project.impl.ProjectInfoWidgetDataConverter.java
License:Open Source License
/** * <b>Quantity of Launches</b> project info widget content * /*w w w . j a v a 2 s. c o m*/ * @param initial * @param interval * @return */ public Map<String, List<ChartObject>> getLaunchesQuantity(List<Launch> initial, InfoInterval interval) { final String START_PERIOD = "start"; final String END_PERIOD = "end"; final String COUNT = "count"; final String INTERVAL = "interval"; HashMap<String, List<ChartObject>> result = new HashMap<>(); if (initial.isEmpty()) { return result; } ProjectInfoGroup criteria = grouping.get(interval); Map<String, List<Launch>> grouped = groupBy(initial, criteria); for (Entry<String, List<Launch>> entry : grouped.entrySet()) { List<Launch> launches = entry.getValue(); Integer count = null != launches ? launches.size() : 0; ChartObject group = new ChartObject(); Map<String, String> values = new HashMap<>(); values.put(COUNT, String.valueOf(count)); values.put(INTERVAL, interval.getInterval()); if (criteria != BY_DAY) { DateTime parse = DateTime.parse(entry.getKey()); // TODO remove Yoda time. replace with JDK8 values.put(START_PERIOD, parse.withDayOfWeek(DateTimeConstants.MONDAY).toString("yyy-MM-dd")); values.put(END_PERIOD, parse.withDayOfWeek(DateTimeConstants.SUNDAY).toString("yyy-MM-dd")); } else { values.put(START_PERIOD, entry.getKey()); } group.setName("Number of launches"); group.setValues(values); result.put(entry.getKey(), Collections.singletonList(group)); } return result; }
From source file:com.github.binlee1990.spider.movie.spider.MovieCrawler.java
License:Apache License
private Date getFilmReleaseDate(String value) { if (StringUtils.isBlank(value)) { return null; }//from w w w. j ava2 s . c o m Date releaseDate = null; String releaseDateStr = StringUtils.EMPTY; if (value.length() >= "2017-01-01".length()) { releaseDateStr = value.substring(0, "2017-01-01".length()); } if (StringUtils.isNotBlank(releaseDateStr)) { try { releaseDate = DateTime.parse(releaseDateStr).toDate(); } catch (Exception e) { } } return releaseDate; }
From source file:com.google.cloud.dns.ChangeRequestInfo.java
License:Open Source License
static ChangeRequestInfo fromPb(Change pb) { Builder builder = builder();/*from www . j a va 2 s . c o m*/ if (pb.getId() != null) { builder.generatedId(pb.getId()); } if (pb.getStartTime() != null) { builder.startTimeMillis(DateTime.parse(pb.getStartTime()).getMillis()); } if (pb.getStatus() != null) { // we are assuming that status indicated in pb is a lower case version of the enum name builder.status(ChangeRequest.Status.valueOf(pb.getStatus().toUpperCase())); } if (pb.getDeletions() != null) { builder.deletions(Lists.transform(pb.getDeletions(), RecordSet.FROM_PB_FUNCTION)); } if (pb.getAdditions() != null) { builder.additions(Lists.transform(pb.getAdditions(), RecordSet.FROM_PB_FUNCTION)); } return builder.build(); }
From source file:com.google.cloud.dns.ZoneInfo.java
License:Open Source License
static ZoneInfo fromPb(ManagedZone pb) { Builder builder = new BuilderImpl(pb.getName()); if (pb.getDescription() != null) { builder.description(pb.getDescription()); }//from w ww. j a v a 2 s. c o m if (pb.getDnsName() != null) { builder.dnsName(pb.getDnsName()); } if (pb.getId() != null) { builder.generatedId(pb.getId().toString()); } if (pb.getNameServers() != null) { builder.nameServers(pb.getNameServers()); } if (pb.getNameServerSet() != null) { builder.nameServerSet(pb.getNameServerSet()); } if (pb.getCreationTime() != null) { builder.creationTimeMillis(DateTime.parse(pb.getCreationTime()).getMillis()); } return builder.build(); }
From source file:com.google.cloud.resourcemanager.ProjectInfo.java
License:Open Source License
static ProjectInfo fromPb(com.google.api.services.cloudresourcemanager.model.Project projectPb) { Builder builder = builder(projectPb.getProjectId()).projectNumber(projectPb.getProjectNumber()); if (projectPb.getName() != null && !projectPb.getName().equals("Unnamed")) { builder.name(projectPb.getName()); }//from w w w. ja v a 2 s. c o m if (projectPb.getLabels() != null) { builder.labels(projectPb.getLabels()); } if (projectPb.getLifecycleState() != null) { builder.state(State.valueOf(projectPb.getLifecycleState())); } if (projectPb.getCreateTime() != null) { builder.createTimeMillis(DateTime.parse(projectPb.getCreateTime()).getMillis()); } if (projectPb.getParent() != null) { builder.parent(ResourceId.fromPb(projectPb.getParent())); } return builder.build(); }