List of usage examples for org.joda.time DateTimeFieldType millisOfSecond
public static DateTimeFieldType millisOfSecond()
From source file:de.openali.odysseus.chart.ext.base.axisrenderer.provider.DateTimeAxisFieldProvider.java
License:Open Source License
@Override public IDateTimeAxisField getDateTimeAxisField(final IDataRange<Number> range) { final long dr = range.getMax().longValue() - range.getMin().longValue(); final long sec = 1000; final long min = 60 * sec; final long hour = 60 * min; final long day = 24 * hour; if (dr < 3 * sec) return new DateTimeAxisField(DateTimeFieldType.millisOfSecond(), "YYYY.dd.MM\nHH:mm:ss:SSS", //$NON-NLS-1$ new int[] { 1, 10, 100, 500 }, new int[] {}); else if (dr < 3 * min) return new DateTimeAxisField(DateTimeFieldType.secondOfMinute(), "YY.dd.MM\nHH:mm:ss", //$NON-NLS-1$ new int[] { 1, 15, 30 }, new int[] {}); else if (dr < 3 * hour) return new DateTimeAxisField(DateTimeFieldType.minuteOfHour(), "YY.dd.MM\nHH:mm:ss", //$NON-NLS-1$ new int[] { 1, 15, 30 }, new int[] {}); else if (dr < 3 * day) return new DateTimeAxisField(DateTimeFieldType.minuteOfDay(), "dd.MM\nHH:mm", new int[] { 1, 15, 30 }, //$NON-NLS-1$ new int[] {}); else if (dr < 7 * day) return new DateTimeAxisField(DateTimeFieldType.hourOfDay(), "dd.MM\nHH:mm", //$NON-NLS-1$ new int[] { 1, 2, 4, 6, 8, 12 }, new int[] { 12 }); else if (dr < 30 * day) return new DateTimeAxisField(DateTimeFieldType.dayOfMonth(), "YYYY.dd.MM\ndddd", //$NON-NLS-1$ new int[] { 1, 2, 7, 14 }, new int[] { 7, 14, 28 }); else/*from www .j a va 2s. co m*/ return new DateTimeAxisField(DateTimeFieldType.monthOfYear(), "YYYY.dd.MM", new int[] { 1, 2, 3, 4, 6 }, //$NON-NLS-1$ new int[] { 6 }); }
From source file:net.karlmartens.platform.datatable.DataTableCell.java
License:Apache License
private static JsonElement creasteJsonElement(Object o) { if (o == null) return JsonNull.INSTANCE; if (o instanceof String) return new JsonPrimitive((String) o); if (o instanceof Boolean) return new JsonPrimitive((Boolean) o); if (o instanceof Number) return new JsonPrimitive((Number) o); if (o instanceof BaseLocal) { final BaseLocal date = (BaseLocal) o; final JsonObject json = new JsonObject(); json.add("year", createJsonElement(DateTimeFieldType.year(), date)); json.add("month", createJsonElement(DateTimeFieldType.monthOfYear(), date)); json.add("day", createJsonElement(DateTimeFieldType.dayOfMonth(), date)); json.add("hour", createJsonElement(DateTimeFieldType.hourOfDay(), date)); json.add("minute", createJsonElement(DateTimeFieldType.minuteOfHour(), date)); json.add("second", createJsonElement(DateTimeFieldType.secondOfMinute(), date)); json.add("millis", createJsonElement(DateTimeFieldType.millisOfSecond(), date)); return json; }/*from ww w . j av a2s .co m*/ throw new UnsupportedOperationException(); }
From source file:org.codelibs.elasticsearch.common.joda.StrictISODateTimeFormat.java
License:Apache License
/** * Adds the time fields to the builder.//from ww w. java 2 s . c om * Specification reference: 5.3.1. * * @param bld the builder * @param fields the fields * @param extended whether to use the extended format * @param strictISO whether to be strict * @param reducedPrec whether the date was reduced precision * @param datePresent whether there was a date * @since 1.1 */ private static void time(DateTimeFormatterBuilder bld, Collection<DateTimeFieldType> fields, boolean extended, boolean strictISO, boolean reducedPrec, boolean datePresent) { boolean hour = fields.remove(DateTimeFieldType.hourOfDay()); boolean minute = fields.remove(DateTimeFieldType.minuteOfHour()); boolean second = fields.remove(DateTimeFieldType.secondOfMinute()); boolean milli = fields.remove(DateTimeFieldType.millisOfSecond()); if (!hour && !minute && !second && !milli) { return; } if (hour || minute || second || milli) { if (strictISO && reducedPrec) { throw new IllegalArgumentException( "No valid ISO8601 format for fields because Date was reduced precision: " + fields); } if (datePresent) { bld.appendLiteral('T'); } } if (hour && minute && second || (hour && !second && !milli)) { // OK - HMSm/HMS/HM/H - valid in combination with date } else { if (strictISO && datePresent) { throw new IllegalArgumentException( "No valid ISO8601 format for fields because Time was truncated: " + fields); } if (!hour && (minute && second || (minute && !milli) || second)) { // OK - MSm/MS/M/Sm/S - valid ISO formats } else { if (strictISO) { throw new IllegalArgumentException("No valid ISO8601 format for fields: " + fields); } } } if (hour) { bld.appendHourOfDay(2); } else if (minute || second || milli) { bld.appendLiteral('-'); } if (extended && hour && minute) { bld.appendLiteral(':'); } if (minute) { bld.appendMinuteOfHour(2); } else if (second || milli) { bld.appendLiteral('-'); } if (extended && minute && second) { bld.appendLiteral(':'); } if (second) { bld.appendSecondOfMinute(2); } else if (milli) { bld.appendLiteral('-'); } if (milli) { bld.appendLiteral('.'); bld.appendMillisOfSecond(3); } }
From source file:org.datavec.api.util.jackson.DateTimeFieldTypeDeserializer.java
License:Apache License
private static Map<String, DateTimeFieldType> getMap() { Map<String, DateTimeFieldType> ret = new HashMap<>(); ret.put(DateTimeFieldType.centuryOfEra().getName(), DateTimeFieldType.centuryOfEra()); ret.put(DateTimeFieldType.clockhourOfDay().getName(), DateTimeFieldType.clockhourOfDay()); ret.put(DateTimeFieldType.clockhourOfHalfday().getName(), DateTimeFieldType.clockhourOfHalfday()); ret.put(DateTimeFieldType.dayOfMonth().getName(), DateTimeFieldType.dayOfMonth()); ret.put(DateTimeFieldType.dayOfWeek().getName(), DateTimeFieldType.dayOfWeek()); ret.put(DateTimeFieldType.dayOfYear().getName(), DateTimeFieldType.dayOfYear()); ret.put(DateTimeFieldType.era().getName(), DateTimeFieldType.era()); ret.put(DateTimeFieldType.halfdayOfDay().getName(), DateTimeFieldType.halfdayOfDay()); ret.put(DateTimeFieldType.hourOfDay().getName(), DateTimeFieldType.hourOfDay()); ret.put(DateTimeFieldType.hourOfHalfday().getName(), DateTimeFieldType.hourOfHalfday()); ret.put(DateTimeFieldType.millisOfDay().getName(), DateTimeFieldType.millisOfDay()); ret.put(DateTimeFieldType.millisOfSecond().getName(), DateTimeFieldType.millisOfSecond()); ret.put(DateTimeFieldType.minuteOfDay().getName(), DateTimeFieldType.minuteOfDay()); ret.put(DateTimeFieldType.minuteOfHour().getName(), DateTimeFieldType.minuteOfHour()); ret.put(DateTimeFieldType.secondOfDay().getName(), DateTimeFieldType.secondOfDay()); ret.put(DateTimeFieldType.secondOfMinute().getName(), DateTimeFieldType.secondOfMinute()); ret.put(DateTimeFieldType.weekOfWeekyear().getName(), DateTimeFieldType.weekOfWeekyear()); ret.put(DateTimeFieldType.weekyear().getName(), DateTimeFieldType.weekyear()); ret.put(DateTimeFieldType.weekyearOfCentury().getName(), DateTimeFieldType.weekyearOfCentury()); ret.put(DateTimeFieldType.year().getName(), DateTimeFieldType.year()); ret.put(DateTimeFieldType.yearOfCentury().getName(), DateTimeFieldType.yearOfCentury()); ret.put(DateTimeFieldType.yearOfEra().getName(), DateTimeFieldType.yearOfEra()); return ret;/*from www.j av a2 s . c o m*/ }
From source file:org.filteredpush.qc.date.DateUtils.java
License:Apache License
/** * Given an instant, return the time within one day that it represents as a string. * //from w w w . j a va 2 s . c o m * @param instant to obtain time from. * @return string in the form hh:mm:ss.sssZ or an empty string if instant is null. */ protected static String instantToStringTime(Instant instant) { String result = ""; if (instant != null) { StringBuffer time = new StringBuffer(); time.append(String.format("%02d", instant.get(DateTimeFieldType.hourOfDay()))); time.append(":").append(String.format("%02d", instant.get(DateTimeFieldType.minuteOfHour()))); time.append(":").append(String.format("%02d", instant.get(DateTimeFieldType.secondOfMinute()))); time.append(".").append(String.format("%03d", instant.get(DateTimeFieldType.millisOfSecond()))); String timeZone = instant.getZone().getID(); if (timeZone.equals("UTC")) { time.append("Z"); } else { time.append(timeZone); } result = time.toString(); } return result; }
From source file:org.gephi.desktop.timeline.DateTick.java
License:Open Source License
public static DateTick create(double min, double max, int width) { DateTime minDate = new DateTime((long) min); DateTime maxDate = new DateTime((long) max); Period period = new Period(minDate, maxDate, PeriodType.yearMonthDayTime()); ;//from w w w . j a v a 2s. c o m int years = period.getYears(); int months = period.getMonths(); int days = period.getDays(); int hours = period.getHours(); int minutes = period.getMinutes(); int seconds = period.getSeconds(); //Top type DateTimeFieldType topType; if (years > 0) { topType = DateTimeFieldType.year(); } else if (months > 0) { topType = DateTimeFieldType.monthOfYear(); } else if (days > 0) { topType = DateTimeFieldType.dayOfMonth(); } else if (hours > 0) { topType = DateTimeFieldType.hourOfDay(); } else if (minutes > 0) { topType = DateTimeFieldType.minuteOfHour(); } else if (seconds > 0) { topType = DateTimeFieldType.secondOfMinute(); } else { topType = DateTimeFieldType.millisOfSecond(); } //Bottom type if (topType != DateTimeFieldType.millisOfSecond()) { DateTimeFieldType bottomType; if (topType.equals(DateTimeFieldType.year())) { bottomType = DateTimeFieldType.monthOfYear(); } else if (topType.equals(DateTimeFieldType.monthOfYear())) { bottomType = DateTimeFieldType.dayOfMonth(); } else if (topType.equals(DateTimeFieldType.dayOfMonth())) { bottomType = DateTimeFieldType.hourOfDay(); } else if (topType.equals(DateTimeFieldType.hourOfDay())) { bottomType = DateTimeFieldType.minuteOfHour(); } else if (topType.equals(DateTimeFieldType.minuteOfHour())) { bottomType = DateTimeFieldType.secondOfMinute(); } else { bottomType = DateTimeFieldType.millisOfSecond(); } //Number of ticks Period p = new Period(minDate, maxDate, PeriodType.forFields(new DurationFieldType[] { bottomType.getDurationType() })); int intervals = p.get(bottomType.getDurationType()); if (intervals > 0) { int intervalSize = width / intervals; if (intervalSize >= MIN_PIXELS) { return new DateTick(minDate, maxDate, new DateTimeFieldType[] { topType, bottomType }); } } } return new DateTick(minDate, maxDate, new DateTimeFieldType[] { topType }); }
From source file:org.wso2.analytics.esb.util.TimeRangeUtils.java
License:Open Source License
public static List<TimeRange> getDateTimeRanges(long from, long to) { List<TimeRange> ranges = new ArrayList<>(10); MutableDateTime fromDate = new MutableDateTime(from); fromDate.set(DateTimeFieldType.millisOfSecond(), 0); MutableDateTime toDate = new MutableDateTime(to); toDate.set(DateTimeFieldType.millisOfSecond(), 0); MutableDateTime tempFromTime = fromDate.copy(); MutableDateTime tempToTime = toDate.copy(); if (log.isDebugEnabled()) { log.debug("Time range: " + formatter.format(fromDate.toDate()) + " -> " + formatter.format(toDate.toDate())); }//from w ww .ja v a2 s . c o m if (toDate.getMillis() - fromDate.getMillis() < DateTimeConstants.MILLIS_PER_MINUTE) { ranges.add(new TimeRange(RangeUnit.SECOND.name(), new long[] { fromDate.getMillis(), toDate.getMillis() })); } else { if (tempFromTime.getSecondOfMinute() != 0 && (toDate.getMillis() - fromDate.getMillis() > DateTimeConstants.MILLIS_PER_MINUTE)) { tempFromTime = tempFromTime.minuteOfHour().roundCeiling(); ranges.add(new TimeRange(RangeUnit.SECOND.name(), new long[] { fromDate.getMillis(), tempFromTime.getMillis() })); } if (tempFromTime.getMinuteOfHour() != 0 && ((toDate.getMillis() - tempFromTime.getMillis()) >= DateTimeConstants.MILLIS_PER_MINUTE)) { fromDate = tempFromTime.copy(); if (((toDate.getMillis() - tempFromTime.getMillis()) / DateTimeConstants.MILLIS_PER_MINUTE) < 60) { tempFromTime = tempFromTime.minuteOfHour().add( (toDate.getMillis() - tempFromTime.getMillis()) / DateTimeConstants.MILLIS_PER_MINUTE); } else { tempFromTime = tempFromTime.hourOfDay().roundCeiling(); } ranges.add(new TimeRange(RangeUnit.MINUTE.name(), new long[] { fromDate.getMillis(), tempFromTime.getMillis() })); } if (tempFromTime.getHourOfDay() != 0 && ((toDate.getMillis() - tempFromTime.getMillis()) >= DateTimeConstants.MILLIS_PER_HOUR)) { fromDate = tempFromTime.copy(); if (((toDate.getMillis() - tempFromTime.getMillis()) / DateTimeConstants.MILLIS_PER_HOUR) < 24) { tempFromTime = tempFromTime.hourOfDay().add( (toDate.getMillis() - tempFromTime.getMillis()) / DateTimeConstants.MILLIS_PER_HOUR); } else { tempFromTime = tempFromTime.dayOfMonth().roundCeiling(); } ranges.add(new TimeRange(RangeUnit.HOUR.name(), new long[] { fromDate.getMillis(), tempFromTime.getMillis() })); } if (tempFromTime.getDayOfMonth() != 1 && ((toDate.getMillis() - tempFromTime.getMillis()) >= DateTimeConstants.MILLIS_PER_DAY)) { fromDate = tempFromTime.copy(); if ((((toDate.getMillis() - tempFromTime.getMillis()) / DateTimeConstants.MILLIS_PER_DAY)) < tempFromTime.dayOfMonth().getMaximumValue()) { tempFromTime = tempFromTime.dayOfMonth().add(((toDate.getMillis() - tempFromTime.getMillis()) / ((long) DateTimeConstants.MILLIS_PER_DAY))); } else { tempFromTime = tempFromTime.monthOfYear().roundCeiling(); } ranges.add(new TimeRange(RangeUnit.DAY.name(), new long[] { fromDate.getMillis(), tempFromTime.getMillis() })); } if (tempToTime.getSecondOfMinute() != 0 && (tempToTime.getMillis() - tempFromTime.getMillis()) >= DateTimeConstants.MILLIS_PER_SECOND) { toDate = tempToTime.copy(); long remainingSeconds = ((toDate.getMillis() - tempFromTime.getMillis()) % DateTimeConstants.MILLIS_PER_MINUTE) / DateTimeConstants.MILLIS_PER_SECOND; if (remainingSeconds < 60) { tempToTime = tempToTime.secondOfMinute().add(-1 * remainingSeconds); } else { tempToTime = tempToTime.secondOfMinute().roundFloor(); } ranges.add(new TimeRange(RangeUnit.SECOND.name(), new long[] { tempToTime.getMillis(), toDate.getMillis() })); } if (tempToTime.getMinuteOfHour() != 0 && ((tempToTime.getMillis() - tempFromTime.getMillis()) >= DateTimeConstants.MILLIS_PER_MINUTE)) { toDate = tempToTime.copy(); long remainingMinutes = ((toDate.getMillis() - tempFromTime.getMillis()) % DateTimeConstants.MILLIS_PER_HOUR) / DateTimeConstants.MILLIS_PER_MINUTE; if (remainingMinutes < 60) { tempToTime = tempToTime.minuteOfHour().add(-1 * remainingMinutes); } else { tempToTime = tempToTime.hourOfDay().roundFloor(); } ranges.add(new TimeRange(RangeUnit.MINUTE.name(), new long[] { tempToTime.getMillis(), toDate.getMillis() })); } if (tempToTime.getHourOfDay() != 0 && ((tempToTime.getMillis() - tempFromTime.getMillis()) >= DateTimeConstants.MILLIS_PER_HOUR)) { toDate = tempToTime.copy(); long remainingHours = ((toDate.getMillis() - tempFromTime.getMillis()) % DateTimeConstants.MILLIS_PER_DAY) / DateTimeConstants.MILLIS_PER_HOUR; if (remainingHours < 24) { tempToTime = tempToTime.hourOfDay().add(-1 * remainingHours); } else { tempToTime = tempToTime.dayOfMonth().roundFloor(); } ranges.add(new TimeRange(RangeUnit.HOUR.name(), new long[] { tempToTime.getMillis(), toDate.getMillis() })); } if (tempToTime.getDayOfMonth() != 1 && ((tempToTime.getMillis() - tempFromTime.getMillis()) >= DateTimeConstants.MILLIS_PER_DAY)) { toDate = tempToTime.copy(); tempToTime = tempToTime.monthOfYear().roundFloor(); ranges.add(new TimeRange(RangeUnit.DAY.name(), new long[] { tempToTime.getMillis(), toDate.getMillis() })); } if (tempToTime.isAfter(tempFromTime)) { ranges.add(new TimeRange(RangeUnit.MONTH.name(), new long[] { tempFromTime.getMillis(), tempToTime.getMillis() })); } } if (log.isDebugEnabled()) { for (TimeRange timeRange : ranges) { log.debug("Unit: " + timeRange.getUnit() + " Range: " + formatter.format(new Date(timeRange.getRange()[0])) + "(" + timeRange.getRange()[0] + ")->" + formatter.format(new Date(timeRange.getRange()[1])) + "(" + timeRange.getRange()[1] + ")"); } } return ranges; }
From source file:org.wso2.analytics.shared.util.time.TimeRangeUtils.java
License:Open Source License
public static List<TimeRange> getDateTimeRanges(long from, long to) { List<TimeRange> ranges = new ArrayList<>(10); MutableDateTime fromDate = new MutableDateTime(from); fromDate.set(DateTimeFieldType.millisOfSecond(), 0); MutableDateTime toDate = new MutableDateTime(to); toDate.set(DateTimeFieldType.millisOfSecond(), 0); MutableDateTime tempFromTime = fromDate.copy(); MutableDateTime tempToTime = toDate.copy(); if (log.isDebugEnabled()) { log.debug("Time range: " + formatter.format(fromDate.toDate()) + "->" + formatter.format(toDate.toDate())); }//from w w w . j a v a 2s . co m if (toDate.getMillis() - fromDate.getMillis() < DateTimeConstants.MILLIS_PER_MINUTE) { ranges.add(new TimeRange(RangeUnit.SECOND.name(), new long[] { fromDate.getMillis(), toDate.getMillis() })); } else { if (tempFromTime.getSecondOfMinute() != 0 && (toDate.getMillis() - fromDate.getMillis() > DateTimeConstants.MILLIS_PER_MINUTE)) { tempFromTime = tempFromTime.minuteOfHour().roundCeiling(); ranges.add(new TimeRange(RangeUnit.SECOND.name(), new long[] { fromDate.getMillis(), tempFromTime.getMillis() })); } if (tempFromTime.getMinuteOfHour() != 0 && ((toDate.getMillis() - tempFromTime.getMillis()) >= DateTimeConstants.MILLIS_PER_MINUTE)) { fromDate = tempFromTime.copy(); if (((toDate.getMillis() - tempFromTime.getMillis()) / DateTimeConstants.MILLIS_PER_MINUTE) < 60) { tempFromTime = tempFromTime.minuteOfHour().add( (toDate.getMillis() - tempFromTime.getMillis()) / DateTimeConstants.MILLIS_PER_MINUTE); } else { tempFromTime = tempFromTime.hourOfDay().roundCeiling(); } ranges.add(new TimeRange(RangeUnit.MINUTE.name(), new long[] { fromDate.getMillis(), tempFromTime.getMillis() })); } if (tempFromTime.getHourOfDay() != 0 && ((toDate.getMillis() - tempFromTime.getMillis()) >= DateTimeConstants.MILLIS_PER_HOUR)) { fromDate = tempFromTime.copy(); if (((toDate.getMillis() - tempFromTime.getMillis()) / DateTimeConstants.MILLIS_PER_HOUR) < 24) { tempFromTime = tempFromTime.hourOfDay().add( (toDate.getMillis() - tempFromTime.getMillis()) / DateTimeConstants.MILLIS_PER_HOUR); } else { tempFromTime = tempFromTime.dayOfMonth().roundCeiling(); } ranges.add(new TimeRange(RangeUnit.HOUR.name(), new long[] { fromDate.getMillis(), tempFromTime.getMillis() })); } if (tempFromTime.getDayOfMonth() != 1 && ((toDate.getMillis() - tempFromTime.getMillis()) >= DateTimeConstants.MILLIS_PER_DAY)) { fromDate = tempFromTime.copy(); if ((((toDate.getMillis() - tempFromTime.getMillis()) / DateTimeConstants.MILLIS_PER_DAY)) < tempFromTime.dayOfMonth().getMaximumValue()) { tempFromTime = tempFromTime.dayOfMonth().add(((toDate.getMillis() - tempFromTime.getMillis()) / ((long) DateTimeConstants.MILLIS_PER_DAY))); } else { tempFromTime = tempFromTime.monthOfYear().roundCeiling(); } ranges.add(new TimeRange(RangeUnit.DAY.name(), new long[] { fromDate.getMillis(), tempFromTime.getMillis() })); } if (tempToTime.getSecondOfMinute() != 0 && (tempToTime.getMillis() - tempFromTime.getMillis()) >= DateTimeConstants.MILLIS_PER_SECOND) { toDate = tempToTime.copy(); long remainingSeconds = ((toDate.getMillis() - tempFromTime.getMillis()) % DateTimeConstants.MILLIS_PER_MINUTE) / DateTimeConstants.MILLIS_PER_SECOND; if (remainingSeconds < 60) { tempToTime = tempToTime.secondOfMinute().add(-1 * remainingSeconds); } else { tempToTime = tempToTime.secondOfMinute().roundFloor(); } ranges.add(new TimeRange(RangeUnit.SECOND.name(), new long[] { tempToTime.getMillis(), toDate.getMillis() })); } if (tempToTime.getMinuteOfHour() != 0 && ((tempToTime.getMillis() - tempFromTime.getMillis()) >= DateTimeConstants.MILLIS_PER_MINUTE)) { toDate = tempToTime.copy(); long remainingMinutes = ((toDate.getMillis() - tempFromTime.getMillis()) % DateTimeConstants.MILLIS_PER_HOUR) / DateTimeConstants.MILLIS_PER_MINUTE; if (remainingMinutes < 60) { tempToTime = tempToTime.minuteOfHour().add(-1 * remainingMinutes); } else { tempToTime = tempToTime.hourOfDay().roundFloor(); } ranges.add(new TimeRange(RangeUnit.MINUTE.name(), new long[] { tempToTime.getMillis(), toDate.getMillis() })); } if (tempToTime.getHourOfDay() != 0 && ((tempToTime.getMillis() - tempFromTime.getMillis()) >= DateTimeConstants.MILLIS_PER_HOUR)) { toDate = tempToTime.copy(); long remainingHours = ((toDate.getMillis() - tempFromTime.getMillis()) % DateTimeConstants.MILLIS_PER_DAY) / DateTimeConstants.MILLIS_PER_HOUR; if (remainingHours < 24) { tempToTime = tempToTime.hourOfDay().add(-1 * remainingHours); } else { tempToTime = tempToTime.dayOfMonth().roundFloor(); } ranges.add(new TimeRange(RangeUnit.HOUR.name(), new long[] { tempToTime.getMillis(), toDate.getMillis() })); } if (tempToTime.getDayOfMonth() != 1 && ((tempToTime.getMillis() - tempFromTime.getMillis()) >= DateTimeConstants.MILLIS_PER_DAY)) { toDate = tempToTime.copy(); tempToTime = tempToTime.monthOfYear().roundFloor(); ranges.add(new TimeRange(RangeUnit.DAY.name(), new long[] { tempToTime.getMillis(), toDate.getMillis() })); } if (tempToTime.isAfter(tempFromTime)) { ranges.add(new TimeRange(RangeUnit.MONTH.name(), new long[] { tempFromTime.getMillis(), tempToTime.getMillis() })); } } if (log.isDebugEnabled()) { for (TimeRange timeRange : ranges) { log.debug("Unit: " + timeRange.getUnit() + " Range: " + formatter.format(new Date(timeRange.getRange()[0])) + "(" + timeRange.getRange()[0] + ")->" + formatter.format(new Date(timeRange.getRange()[1])) + "(" + timeRange.getRange()[1] + ")"); } } return ranges; }
From source file:TVShowTimelineMaker.util.JodaTimeUtil.java
private void init() { // <editor-fold defaultstate="collapsed" desc="StandardDateTimeFieldTypeMap setup"> this.StandardDateTimeFieldTypeMap.put(DateTimeFieldType.centuryOfEra().getName(), DateTimeFieldType.centuryOfEra()); this.StandardDateTimeFieldTypeMap.put(DateTimeFieldType.clockhourOfDay().getName(), DateTimeFieldType.clockhourOfDay()); this.StandardDateTimeFieldTypeMap.put(DateTimeFieldType.clockhourOfHalfday().getName(), DateTimeFieldType.clockhourOfHalfday()); this.StandardDateTimeFieldTypeMap.put(DateTimeFieldType.dayOfMonth().getName(), DateTimeFieldType.dayOfMonth()); this.StandardDateTimeFieldTypeMap.put(DateTimeFieldType.dayOfWeek().getName(), DateTimeFieldType.dayOfWeek()); this.StandardDateTimeFieldTypeMap.put(DateTimeFieldType.dayOfYear().getName(), DateTimeFieldType.dayOfYear()); this.StandardDateTimeFieldTypeMap.put(DateTimeFieldType.era().getName(), DateTimeFieldType.era()); this.StandardDateTimeFieldTypeMap.put(DateTimeFieldType.halfdayOfDay().getName(), DateTimeFieldType.halfdayOfDay()); this.StandardDateTimeFieldTypeMap.put(DateTimeFieldType.hourOfDay().getName(), DateTimeFieldType.hourOfDay()); this.StandardDateTimeFieldTypeMap.put(DateTimeFieldType.hourOfHalfday().getName(), DateTimeFieldType.hourOfHalfday()); this.StandardDateTimeFieldTypeMap.put(DateTimeFieldType.millisOfDay().getName(), DateTimeFieldType.millisOfDay()); this.StandardDateTimeFieldTypeMap.put(DateTimeFieldType.millisOfSecond().getName(), DateTimeFieldType.millisOfSecond()); this.StandardDateTimeFieldTypeMap.put(DateTimeFieldType.minuteOfDay().getName(), DateTimeFieldType.minuteOfDay()); this.StandardDateTimeFieldTypeMap.put(DateTimeFieldType.minuteOfHour().getName(), DateTimeFieldType.minuteOfHour()); this.StandardDateTimeFieldTypeMap.put(DateTimeFieldType.monthOfYear().getName(), DateTimeFieldType.monthOfYear()); this.StandardDateTimeFieldTypeMap.put(DateTimeFieldType.secondOfDay().getName(), DateTimeFieldType.secondOfDay()); this.StandardDateTimeFieldTypeMap.put(DateTimeFieldType.secondOfMinute().getName(), DateTimeFieldType.secondOfMinute()); this.StandardDateTimeFieldTypeMap.put(DateTimeFieldType.weekOfWeekyear().getName(), DateTimeFieldType.weekOfWeekyear()); this.StandardDateTimeFieldTypeMap.put(DateTimeFieldType.weekyear().getName(), DateTimeFieldType.weekyear()); this.StandardDateTimeFieldTypeMap.put(DateTimeFieldType.weekyearOfCentury().getName(), DateTimeFieldType.weekyearOfCentury()); this.StandardDateTimeFieldTypeMap.put(DateTimeFieldType.year().getName(), DateTimeFieldType.year()); this.StandardDateTimeFieldTypeMap.put(DateTimeFieldType.yearOfCentury().getName(), DateTimeFieldType.yearOfCentury()); this.StandardDateTimeFieldTypeMap.put(DateTimeFieldType.yearOfEra().getName(), DateTimeFieldType.yearOfEra()); // </editor-fold> // <editor-fold defaultstate="collapsed" desc="ChronologyMap setup"> this.ChronologybidiMap.put("BuddhistChronology", org.joda.time.chrono.BuddhistChronology.class); this.ChronologybidiMap.put("CopticChronology", org.joda.time.chrono.CopticChronology.class); this.ChronologybidiMap.put("EthiopicChronology", org.joda.time.chrono.EthiopicChronology.class); this.ChronologybidiMap.put("GJChronology", org.joda.time.chrono.GJChronology.class); this.ChronologybidiMap.put("GregorianChronology", org.joda.time.chrono.GregorianChronology.class); this.ChronologybidiMap.put("ISOChronology", org.joda.time.chrono.ISOChronology.class); this.ChronologybidiMap.put("IslamicChronology", org.joda.time.chrono.IslamicChronology.class); this.ChronologybidiMap.put("JulianChronology", org.joda.time.chrono.JulianChronology.class); this.ChronologyInstanceMap.put("BuddhistChronology", org.joda.time.chrono.BuddhistChronology.getInstance()); this.ChronologyInstanceMap.put("CopticChronology", org.joda.time.chrono.CopticChronology.getInstance()); this.ChronologyInstanceMap.put("EthiopicChronology", org.joda.time.chrono.EthiopicChronology.getInstance()); this.ChronologyInstanceMap.put("GJChronology", org.joda.time.chrono.GJChronology.getInstance()); this.ChronologyInstanceMap.put("GregorianChronology", org.joda.time.chrono.GregorianChronology.getInstance()); this.ChronologyInstanceMap.put("ISOChronology", org.joda.time.chrono.ISOChronology.getInstance()); this.ChronologyInstanceMap.put("IslamicChronology", org.joda.time.chrono.IslamicChronology.getInstance()); this.ChronologyInstanceMap.put("JulianChronology", org.joda.time.chrono.JulianChronology.getInstance()); // </editor-fold> }