List of usage examples for org.joda.time DateTime toString
@ToString
public String toString()
From source file:com.sos.hibernate.classes.UtcTimeHelper.java
License:Apache License
public static Date convertTimeZonesToDate(String fromTimeZone, String toTimeZone, DateTime fromDateTime) { if (fromDateTime == null) { return null; }//from w ww . j a va 2s . co m DateTimeZone fromZone = DateTimeZone.forID(fromTimeZone); DateTimeZone toZone = DateTimeZone.forID(toTimeZone); DateTime dateTime = new DateTime(fromDateTime); dateTime = dateTime.withZoneRetainFields(fromZone); DateTime toDateTime = new DateTime(dateTime).withZone(toZone); DateTimeFormatter oFormatter = DateTimeFormat.forPattern("yyyy-MM-dd'T'H:mm:ss.SSSZ"); DateTimeFormatter oFormatter2 = DateTimeFormat.forPattern("yyyy-MM-dd H:mm:ss.ss"); DateTime newDate = oFormatter.withOffsetParsed().parseDateTime(toDateTime.toString()); try { return new SimpleDateFormat("yyyy-MM-dd H:mm:ss.ss") .parse(oFormatter2.withZone(toZone).print(newDate.getMillis())); } catch (ParseException e) { e.printStackTrace(); return null; } }
From source file:com.stormpath.sdk.impl.query.DefaultDateExpressionFactory.java
License:Apache License
@Override public Criterion gt(Date date) { Assert.notNull(date, "date needs to be a valid Date object"); DateTime dateTime = new DateTime(date); String value = EXCLUSIVE_OPENING + dateTime.toString() + COMMA + INCLUSIVE_CLOSING; return new SimpleExpression(propertyName, value, Operator.EQUALS); }
From source file:com.stormpath.sdk.impl.query.DefaultDateExpressionFactory.java
License:Apache License
@Override public Criterion gte(Date date) { Assert.notNull(date, "date needs to be a valid Date object"); DateTime dateTime = new DateTime(date); String value = INCLUSIVE_OPENING + dateTime.toString() + COMMA + INCLUSIVE_CLOSING; return new SimpleExpression(propertyName, value, Operator.EQUALS); }
From source file:com.stormpath.sdk.impl.query.DefaultDateExpressionFactory.java
License:Apache License
@Override public Criterion lt(Date date) { Assert.notNull(date, "date needs to be a valid Date object"); DateTime dateTime = new DateTime(date); String value = INCLUSIVE_OPENING + COMMA + dateTime.toString() + EXCLUSIVE_CLOSING; return new SimpleExpression(propertyName, value, Operator.EQUALS); }
From source file:com.stormpath.sdk.impl.query.DefaultDateExpressionFactory.java
License:Apache License
@Override public Criterion lte(Date date) { Assert.notNull(date, "date needs to be a valid Date object"); DateTime dateTime = new DateTime(date); String value = INCLUSIVE_OPENING + COMMA + dateTime.toString() + INCLUSIVE_CLOSING; return new SimpleExpression(propertyName, value, Operator.EQUALS); }
From source file:com.stormpath.sdk.impl.query.DefaultDateExpressionFactory.java
License:Apache License
@Override public Criterion equals(Date date) { Assert.notNull(date, "date needs to be a valid Date object"); DateTime dateTime = new DateTime(date); return new SimpleExpression(propertyName, dateTime.toString(), Operator.EQUALS); }
From source file:com.stormpath.sdk.impl.query.DefaultDateExpressionFactory.java
License:Apache License
@Override public Criterion in(Date begin, Date end) { Assert.notNull(begin, "begin needs to be a valid Date object"); Assert.notNull(end, "end needs to be a valid Date object"); Assert.isTrue(begin.before(end), "begin date needs to be earlier than end date"); DateTime beginDateTime = new DateTime(begin); DateTime endDateTime = new DateTime(end); String value = INCLUSIVE_OPENING + beginDateTime.toString() + COMMA + endDateTime.toString() + EXCLUSIVE_CLOSING;// w ww. ja v a2 s .c o m return new SimpleExpression(propertyName, value, Operator.EQUALS); }
From source file:com.stormpath.sdk.impl.query.DefaultDateExpressionFactory.java
License:Apache License
@Override public Criterion in(Date begin, Duration duration) { Assert.isTrue(begin instanceof Date, "begin needs to be a valid Date object"); Assert.isTrue(duration instanceof Duration, "duration needs to be a valid Duration object"); DateTime beginDateTime = new DateTime(begin); Date endDate = this.calculateDateFromDuration(begin, duration); Assert.isTrue(begin.before(endDate), "begin date needs to be earlier than end date"); DateTime endDateTime = new DateTime(endDate); String value = INCLUSIVE_OPENING + beginDateTime.toString() + COMMA + endDateTime.toString() + EXCLUSIVE_CLOSING;//w w w .j ava 2 s . c om return new SimpleExpression(propertyName, value, Operator.EQUALS); }
From source file:com.thinkbiganalytics.jpa.LongColumnDateTimeMapper.java
License:Apache License
public String toNonNullString(DateTime value) { return value.toString(); }
From source file:com.thinkbiganalytics.metadata.sla.api.core.FeedFailureMetricAssessor.java
License:Apache License
@Override public void assess(FeedFailedMetric metric, MetricAssessmentBuilder<Serializable> builder) { builder.metric(metric);/* ww w .j a v a 2s. co m*/ String feedName = metric.getFeedName(); HashMap<String, String> data = new HashMap<>(); data.put("feed", feedName); FeedFailureService.LastFeedJob lastFeedJob = feedFailureService.findLatestJob(feedName); DateTime lastTime = lastFeedJob.getDateTime(); data.put("dateTime", lastTime.toString()); data.put("dateTimeMillis", lastTime.getMillis() + ""); LOG.debug("Assessing FeedFailureMetric for '{}'. The Last Feed Job was: {} ", feedName, lastFeedJob); if (!feedFailureService.isEmptyJob(lastFeedJob)) { if (lastFeedJob.getBatchJobExecutionId() != null) { data.put("jobExecutionId", lastFeedJob.getBatchJobExecutionId().toString()); } //compare with the latest feed time, alerts with same timestamps will not be raised builder.compareWith(feedName, lastTime.getMillis()); if (lastFeedJob.isFailure()) { data.put("status", "FAILURE"); String message = "Feed " + feedName + " has failed on " + lastFeedJob.getDateTime(); if (lastFeedJob.getBatchJobExecutionId() != null) { message += ". Batch Job ExecutionId: " + lastFeedJob.getBatchJobExecutionId(); } LOG.debug(message); builder.message(message).data(data).result(AssessmentResult.FAILURE); } else { data.put("status", "SUCCESS"); String message = "Feed " + feedName + " has succeeded on " + lastFeedJob.getDateTime(); if (lastFeedJob.getBatchJobExecutionId() != null) { message += ". Batch Job ExecutionId: " + lastFeedJob.getBatchJobExecutionId(); } LOG.debug(message); builder.message(message).data(data).result(AssessmentResult.SUCCESS); } } else { LOG.debug("FeedFailureMetric found an no recent jobs for '{}'. Returning SUCCESS ", feedName); builder.data(data).message("No Jobs found for feed " + feedName + " since " + lastFeedJob.getDateTime()) .result(AssessmentResult.SUCCESS); } }