@Override public Duration getGranularity() { Period res = new Period(); res = res.withField(JodaTimeUtils.getMostSpecific(getJodaTimePeriod()), 1); return Duration.getDuration(res); }
@Override public boolean hasTime() { if (base == null) return false; DateTimeFieldType sdft = JodaTimeUtils.getMostSpecific(base); if (sdft != null && JodaTimeUtils.isMoreGeneral(DateTimeFieldType.dayOfMonth(), sdft, base.getChronology())) { return true; } else { return false; } }
@Override public PartialTime reduceGranularityTo(Duration granularity) { Partial p = JodaTimeUtils.discardMoreSpecificFields( base, JodaTimeUtils.getMostSpecific(granularity.getJodaTimePeriod()) ); return new CompositePartialTime(this, p, poy.reduceGranularityTo(granularity), dow.reduceGranularityTo(granularity), tod.reduceGranularityTo(granularity)); }
@Override public PartialTime reduceGranularityTo(Duration granularity) { Partial pbase = base; if (JodaTimeUtils.hasField(granularity.getJodaTimePeriod(), DurationFieldType.weeks())) { // Make sure the partial time has weeks in it if (!JodaTimeUtils.hasField(pbase, DateTimeFieldType.weekOfWeekyear())) { // Add week year to it pbase = JodaTimeUtils.resolveWeek(pbase); } } Partial p = JodaTimeUtils.discardMoreSpecificFields( pbase, JodaTimeUtils.getMostSpecific(granularity.getJodaTimePeriod()) ); return new PartialTime(this,p); }
public static Partial resolveDowToDay(Partial p) { if (p.isSupported(DateTimeFieldType.dayOfWeek())) { if (!p.isSupported(DateTimeFieldType.dayOfMonth())) { if (p.isSupported(DateTimeFieldType.weekOfWeekyear()) && (p.isSupported(DateTimeFieldType.year()))) { // Convert from year to weekyear (to avoid weirdness when the weekyear and year don't match at the beginning of the year) Partial pwy = withWeekYear(p); Instant t2 = getInstant(pwy); DateTime t1 = pwy.toDateTime(t2); Partial res = getPartial(t1.toInstant(), EMPTY_ISO_PARTIAL); DateTimeFieldType mostSpecific = getMostSpecific(p); res = discardMoreSpecificFields(res, mostSpecific.getDurationType()); return res; } } } return p; }
protected boolean appendTimeFormats(DateTimeFormatterBuilder builder, int flags) { boolean alwaysPad = ((flags & FORMAT_PAD_UNKNOWN) != 0); boolean hasTime = hasTime(); DateTimeFieldType sdft = JodaTimeUtils.getMostSpecific(base); if (hasTime) { builder.appendLiteral("T");
public static Partial padMoreSpecificFields(Partial p, Period granularity) DateTimeFieldType msf = getMostSpecific(p); if (isMoreGeneral(msf, DateTimeFieldType.year(), p.getChronology()) || isMoreGeneral(msf, DateTimeFieldType.yearOfCentury(), p.getChronology())) { DurationFieldType mostSpecific = getMostSpecific(granularity); p = discardMoreSpecificFields(p, mostSpecific);
@Override public Duration getGranularity() { Period res = new Period(); res = res.withField(JodaTimeUtils.getMostSpecific(getJodaTimePeriod()), 1); return Duration.getDuration(res); }
public Duration getGranularity() { Period res = new Period(); res = res.withField(JodaTimeUtils.getMostSpecific(getJodaTimePeriod()), 1); return Duration.getDuration(res); }
public boolean hasTime() { if (base == null) return false; DateTimeFieldType sdft = JodaTimeUtils.getMostSpecific(base); if (sdft != null && JodaTimeUtils.isMoreGeneral(DateTimeFieldType.dayOfMonth(), sdft, base.getChronology())) { return true; } else { return false; } }
public boolean hasTime() { if (base == null) return false; DateTimeFieldType sdft = JodaTimeUtils.getMostSpecific(base); if (sdft != null && JodaTimeUtils.isMoreGeneral(DateTimeFieldType.dayOfMonth(), sdft, base.getChronology())) { return true; } else { return false; } }
@Override public boolean hasTime() { if (base == null) return false; DateTimeFieldType sdft = JodaTimeUtils.getMostSpecific(base); if (sdft != null && JodaTimeUtils.isMoreGeneral(DateTimeFieldType.dayOfMonth(), sdft, base.getChronology())) { return true; } else { return false; } }
public PartialTime reduceGranularityTo(Duration granularity) { Partial p = JodaTimeUtils.discardMoreSpecificFields( base, JodaTimeUtils.getMostSpecific(granularity.getJodaTimePeriod()) ); return new CompositePartialTime(this, p, poy.reduceGranularityTo(granularity), dow.reduceGranularityTo(granularity), tod.reduceGranularityTo(granularity)); }
@Override public PartialTime reduceGranularityTo(Duration granularity) { Partial p = JodaTimeUtils.discardMoreSpecificFields( base, JodaTimeUtils.getMostSpecific(granularity.getJodaTimePeriod()) ); return new CompositePartialTime(this, p, poy.reduceGranularityTo(granularity), dow.reduceGranularityTo(granularity), tod.reduceGranularityTo(granularity)); }
public PartialTime reduceGranularityTo(Duration granularity) { Partial pbase = base; if (JodaTimeUtils.hasField(granularity.getJodaTimePeriod(), DurationFieldType.weeks())) { // Make sure the partial time has weeks in it if (!JodaTimeUtils.hasField(pbase, DateTimeFieldType.weekOfWeekyear())) { // Add week year to it pbase = JodaTimeUtils.resolveWeek(pbase); } } Partial p = JodaTimeUtils.discardMoreSpecificFields( pbase, JodaTimeUtils.getMostSpecific(granularity.getJodaTimePeriod()) ); return new PartialTime(this,p); }
@Override public PartialTime reduceGranularityTo(Duration granularity) { Partial pbase = base; if (JodaTimeUtils.hasField(granularity.getJodaTimePeriod(), DurationFieldType.weeks())) { // Make sure the partial time has weeks in it if (!JodaTimeUtils.hasField(pbase, DateTimeFieldType.weekOfWeekyear())) { // Add week year to it pbase = JodaTimeUtils.resolveWeek(pbase); } } Partial p = JodaTimeUtils.discardMoreSpecificFields( pbase, JodaTimeUtils.getMostSpecific(granularity.getJodaTimePeriod()) ); return new PartialTime(this,p); }
public static Partial resolveDowToDay(Partial p) { if (p.isSupported(DateTimeFieldType.dayOfWeek())) { if (!p.isSupported(DateTimeFieldType.dayOfMonth())) { if (p.isSupported(DateTimeFieldType.weekOfWeekyear()) && p.isSupported(DateTimeFieldType.year())) { Instant t2 = getInstant(p); DateTime t1 = p.toDateTime(t2); Partial res = getPartial(t1.toInstant(), EMPTY_ISO_PARTIAL); DateTimeFieldType mostSpecific = getMostSpecific(p); res = discardMoreSpecificFields(res, mostSpecific.getDurationType()); return res; } } } return p; } // Uses p2 to resolve week for p1
public static Partial resolveDowToDay(Partial p) { if (p.isSupported(DateTimeFieldType.dayOfWeek())) { if (!p.isSupported(DateTimeFieldType.dayOfMonth())) { if (p.isSupported(DateTimeFieldType.weekOfWeekyear()) && p.isSupported(DateTimeFieldType.year())) { Instant t2 = getInstant(p); DateTime t1 = p.toDateTime(t2); Partial res = getPartial(t1.toInstant(), EMPTY_ISO_PARTIAL); DateTimeFieldType mostSpecific = getMostSpecific(p); res = discardMoreSpecificFields(res, mostSpecific.getDurationType()); return res; } } } return p; } // Uses p2 to resolve week for p1
public static Partial resolveDowToDay(Partial p) { if (p.isSupported(DateTimeFieldType.dayOfWeek())) { if (!p.isSupported(DateTimeFieldType.dayOfMonth())) { if (p.isSupported(DateTimeFieldType.weekOfWeekyear()) && (p.isSupported(DateTimeFieldType.year()))) { // Convert from year to weekyear (to avoid weirdness when the weekyear and year don't match at the beginning of the year) Partial pwy = withWeekYear(p); Instant t2 = getInstant(pwy); DateTime t1 = pwy.toDateTime(t2); Partial res = getPartial(t1.toInstant(), EMPTY_ISO_PARTIAL); DateTimeFieldType mostSpecific = getMostSpecific(p); res = discardMoreSpecificFields(res, mostSpecific.getDurationType()); return res; } } } return p; }
protected boolean appendTimeFormats(DateTimeFormatterBuilder builder, int flags) { boolean alwaysPad = ((flags & FORMAT_PAD_UNKNOWN) != 0); boolean hasTime = hasTime(); DateTimeFieldType sdft = JodaTimeUtils.getMostSpecific(base); if (hasTime) { builder.appendLiteral("T");