public int getField(DateTime dateTime) { return dateTime.get(this.dateTimeField); }
public int parseInto(DateTimeParserBucket bucket, String text, int position) { String substr = text.substring(position); Matcher matcher = numericMatcher.get(); matcher.reset(substr); if (!matcher.matches()) { return -1; } // Joda DateTime only has precision to millis, cut off any fractional portion long millis = Long.parseLong(matcher.group(1)); DateTime dt = new DateTime(millis, ISOChronology.getInstanceUTC()); for (DateTimeFieldType field : dateTimeFields) { bucket.saveField(field, dt.get(field)); } return substr.length(); } }
public int getField(DateTime dateTime) { return dateTime.get(this.dateTimeField); }
public int getField(DateTime dateTime) { return dateTime.get(this.dateTimeField); }
private String dateString (DateTime dateTime) { // Parse out year, month, day, and hour out of DateTime int y = dateTime.get(DateTimeFieldType.year()); int m = dateTime.get(DateTimeFieldType.monthOfYear()); int d = dateTime.get(DateTimeFieldType.dayOfMonth()); int h = dateTime.get(DateTimeFieldType.clockhourOfDay()) % 24; return String.format("%04d%02d%02d%02d", y, m, d, h); }
private String dateStringLong (DateTime dateTime) { // Parse out year, month, day, and hour out of DateTime int y = dateTime.get(DateTimeFieldType.year()); int m = dateTime.get(DateTimeFieldType.monthOfYear()); int d = dateTime.get(DateTimeFieldType.dayOfMonth()); int h = dateTime.get(DateTimeFieldType.clockhourOfDay()) % 24; return String.format("%04d-%02d-%02d %02d:00", y, m, d, h); }
public BirthTime() { Date date = new Date(); DateTime dt = new DateTime(date); this.year = dt.get(DateTimeFieldType.year()); this.month = dt.get(DateTimeFieldType.monthOfYear()); this.day = dt.get(DateTimeFieldType.dayOfMonth()); this.hour = dt.get(DateTimeFieldType.hourOfDay()); this.minutes = dt.get(DateTimeFieldType.minuteOfHour()); }
public BirthTime(Date date) { DateTime dt = new DateTime(date); this.year = dt.get(DateTimeFieldType.year()); this.month = dt.get(DateTimeFieldType.monthOfYear()); this.day = dt.get(DateTimeFieldType.dayOfMonth()); this.hour = dt.get(DateTimeFieldType.hourOfDay()); this.minutes = dt.get(DateTimeFieldType.minuteOfHour()); }
public int getFieldValue(CalendarPeriod.Field fld) { switch (fld) { case Day: return dateTime.get(DateTimeFieldType.dayOfMonth()); case Hour: return dateTime.get(DateTimeFieldType.hourOfDay()); case Millisec: return dateTime.get(DateTimeFieldType.millisOfSecond()); case Minute: return dateTime.get(DateTimeFieldType.minuteOfHour()); case Month: return dateTime.get(DateTimeFieldType.monthOfYear()); case Second: return dateTime.get(DateTimeFieldType.secondOfMinute()); case Year: return dateTime.get(DateTimeFieldType.year()); } throw new IllegalArgumentException("unimplemented "+fld); }
public int parseInto(DateTimeParserBucket bucket, String text, int position) { String substr = text.substring(position); Matcher matcher = numericMatcher.get(); matcher.reset(substr); if (!matcher.matches()) { return -1; } // Joda DateTime only has precision to millis, cut off any fractional portion long millis = Long.parseLong(matcher.group(1)); DateTime dt = new DateTime(millis, ISOChronology.getInstanceUTC()); for (DateTimeFieldType field : dateTimeFields) { bucket.saveField(field, dt.get(field)); } return substr.length(); } }
private Node getInstantViaClosestChild(Node parent, DateTime dateTime, Resolution targetResolution, ChildNotFoundPolicy childNotFoundPolicy, Resolution newCurrentResolution, RelationshipType relationshipType) { Node closestChild = findChild(parent, dateTime.get(newCurrentResolution.getDateTimeFieldType()), childNotFoundPolicy); if (closestChild == null) { return null; } return findChild(closestChild, relationshipType, targetResolution); }
public int getAcademicSemesterOfAcademicYear(final AcademicChronology academicChronology) { return getBegin().withChronology(academicChronology).get( AcademicSemesterOfAcademicYearDateTimeFieldType.academicSemesterOfAcademicYear()); }
public AcademicSemesterCE minusSemester(int amount) { int index = getStart().get(AcademicSemesterDateTimeFieldType.academicSemester()); return getAcademicChronology().getAcademicSemesterIn(index - amount); }
public AcademicSemesterCE plusSemester(int amount) { int index = getStart().get(AcademicSemesterDateTimeFieldType.academicSemester()); return getAcademicChronology().getAcademicSemesterIn(index + amount); }
public AcademicYearCE minusYear(int amount) { int index = getStart().get(AcademicYearDateTimeFieldType.academicYear()); return getAcademicChronology().getAcademicYearIn(index - amount); }
public AcademicYearCE plusYear(int amount) { int index = getStart().get(AcademicYearDateTimeFieldType.academicYear()); return getAcademicChronology().getAcademicYearIn(index + amount); }
protected DateTime every(DateTime currentTime, DateTimeFieldType unit, int offset, int interval) { DateTime d = currentTime.property(unit).roundFloorCopy(); d = d.withFieldAdded(unit.getDurationType(), offset); return d.withField(unit, (d.get(unit) / interval) * interval); }
private Node getInstant(Node parent, DateTime dateTime, Resolution targetResolution, ChildNotFoundPolicy childNotFoundPolicy) { Resolution currentResolution = currentResolution(parent); if (targetResolution.equals(currentResolution)) { return parent; } Resolution newCurrentResolution = childResolution(parent); Node child = findChild(parent, dateTime.get(newCurrentResolution.getDateTimeFieldType()), RETURN_NULL); if (child == null) { switch (childNotFoundPolicy) { case RETURN_NULL: return null; case RETURN_NEXT: return getInstantViaClosestChild(parent, dateTime, targetResolution, childNotFoundPolicy, newCurrentResolution, FIRST); case RETURN_PREVIOUS: return getInstantViaClosestChild(parent, dateTime, targetResolution, childNotFoundPolicy, newCurrentResolution, LAST); } } //recursion return getInstant(child, dateTime, targetResolution, childNotFoundPolicy); }