List of usage examples for org.joda.time Period toString
@ToString
public String toString()
From source file:com.allogy.json.jackson.joda.ISOPeriodSerializer.java
License:Apache License
@Override public void serialize(Period period, JsonGenerator jsonGenerator, SerializerProvider serializerProvider) throws IOException, JsonProcessingException { jsonGenerator.writeString(period.toString()); }
From source file:com.enonic.cms.business.portal.datasource.expressionfunctions.ExpressionFunctions.java
License:Open Source License
public String periodHoursMinutes(int hours, int minutes) { Period period = new Period(hours, minutes, 0, 0); return period.toString(); }
From source file:com.ethercis.servicemanager.common.IsoDateJoda.java
License:Apache License
/** * Calculate the difference from the given time to now. * ISO 8601 states: Durations are represented by the format P[n]Y[n]M[n]DT[n]H[n]M[n]S * @param utc Given time, e.g. "1997-07-16T19:20:30.45+01:00" * @return The ISO 8601 Period like "P3Y6M4DT12H30M17S" *//*from w ww. j a va 2 s. com*/ public static String getDifferenceToNow(String utc) { if (utc == null) return ""; utc = ReplaceVariable.replaceAll(utc, " ", "T"); DateTime now = new DateTime(); DateTimeFormatter f = ISODateTimeFormat.dateTimeParser(); DateTime other = f.parseDateTime(utc); Period period = new Period(other, now); // Period(ReadableInstant startInstant, ReadableInstant endInstant) return period.toString(); }
From source file:com.talvish.tales.parts.translators.PeriodToStringTranslator.java
License:Apache License
/** * Translates the received object into a string. * If the object to translate isn't null but is of the wrong * type, a TranslationException will occur. *//* w w w. ja va 2 s . co m*/ @Override public Object translate(Object anObject) { Object returnValue; if (anObject == null) { returnValue = this.nullValue; } else { try { Period value = (Period) anObject; if (formatter == null) { returnValue = value.toString(); } else { returnValue = value.toString(formatter); } } catch (ClassCastException e) { throw new TranslationException(e); } } return returnValue; }
From source file:com.thinkbiganalytics.metadata.api.sla.WithinSchedule.java
License:Apache License
public WithinSchedule(CronExpression cronExpression, Period period) throws ParseException { this.cronExpression = cronExpression; this.period = period; this.cronString = cronExpression.toString(); this.periodString = period.toString(); }
From source file:com.thinkbiganalytics.policy.precondition.FeedExecutedSinceFeedsOrTime.java
License:Apache License
@Override public Set<com.thinkbiganalytics.metadata.rest.model.sla.ObligationGroup> buildPreconditionObligations() { Set<com.thinkbiganalytics.metadata.rest.model.sla.ObligationGroup> preconditionGroups = new HashSet<>(); preconditionGroups.addAll(super.buildPreconditionObligations()); try {//www .j ava 2 s . c om Period p = new Period(0, 0, 1, 0); String withinPeriod = p.toString(); WithinSchedule metric = new WithinSchedule(cronExpression, withinPeriod); Obligation obligation = new Obligation(); obligation.setMetrics(Lists.newArrayList(metric)); com.thinkbiganalytics.metadata.rest.model.sla.ObligationGroup group = new com.thinkbiganalytics.metadata.rest.model.sla.ObligationGroup(); group.addObligation(obligation); group.setCondition(ObligationGroup.Condition.SUFFICIENT.name()); preconditionGroups.add(group); } catch (ParseException e) { } return preconditionGroups; }
From source file:ee.ut.soras.test_ajavt.KiiruseTestiTulemus.java
License:Open Source License
private String convertToOtherFields(double timeInMills) { Period p = new Period((long) timeInMills, PeriodType.millis()); p = p.normalizedStandard();//from www . j a v a 2 s .c om DurationFieldType[] fieldTypes = p.getFieldTypes(); int[] values = p.getValues(); if (values.length == fieldTypes.length) { StringBuilder sb = new StringBuilder(); for (int i = 0; i < values.length; i++) { if (values[i] != 0) { sb.append(values[i] + " " + fieldTypes[i].getName() + " "); } } return sb.toString(); } return p.toString(); }
From source file:energy.usef.core.adapter.YodaTimeAdapter.java
License:Apache License
/** * Transforms a {@link Period} to a String (xsd:duration) . * // www . ja v a 2s . c o m * @param period {@link Period} * @return String (xsd:duration) */ public static String printDuration(Period period) { if (period == null) { return null; } return period.toString(); }
From source file:gg.db.datamodel.Periods.java
License:Open Source License
@Override public String toString() { String description = "start=" + start + " - end=" + end + " - period type=" + periodType + "\n"; for (Period period : periods) { description += period.toString() + "\n"; }/*w ww. j a v a2 s. c o m*/ return description; }
From source file:google.registry.xml.PeriodAdapter.java
License:Open Source License
@Nullable @Override public String marshal(@Nullable Period period) { return period == null ? null : period.toString(); }