List of usage examples for org.joda.time LocalDate getDayOfMonth
public int getDayOfMonth()
From source file:org.estatio.services.clock.ClockService.java
License:Apache License
static LocalDate beginningOfMonth(final LocalDate date) { final int dayOfMonth = date.getDayOfMonth(); return date.minusDays(dayOfMonth - 1); }
From source file:org.fornax.cartridges.sculptor.framework.richclient.databinding.JodaLocalDateObservableValue.java
License:Apache License
private void setLocalDateSelection(LocalDate date) { if (date == null) { // TODO how to handle null date = new LocalDate(); }/*w w w . ja va2 s. c o m*/ dateTime.setYear(date.getYear()); dateTime.setMonth(date.getMonthOfYear() - 1); dateTime.setDay(date.getDayOfMonth()); }
From source file:org.goobi.production.model.bibliography.course.CourseToGerman.java
License:Open Source License
/** * The method appendManyDates() converts a lot of date objects into readable * text in German language./* ww w .j av a 2 s .c o m*/ * * @param buffer * StringBuilder to write to * @param dates * Set of dates to convert to text * @param signum * sign, i.e. true for additions, false for exclusions * @throws NoSuchElementException * if dates has no elements * @throws NullPointerException * if buffer or dates is null */ private static void appendManyDates(StringBuilder buffer, Set<LocalDate> dates, boolean signum) { if (signum) { buffer.append("zustzlich "); } else { buffer.append("nicht "); } TreeSet<LocalDate> orderedDates = dates instanceof TreeSet ? (TreeSet<LocalDate>) dates : new TreeSet<>(dates); Iterator<LocalDate> datesIterator = orderedDates.iterator(); LocalDate current = datesIterator.next(); LocalDate next = datesIterator.hasNext() ? datesIterator.next() : null; LocalDate overNext = datesIterator.hasNext() ? datesIterator.next() : null; int previousYear = Integer.MIN_VALUE; boolean nextInSameMonth = false; boolean nextBothInSameMonth = next != null && DateUtils.sameMonth(current, next); int lastMonthOfYear = DateUtils.lastMonthForYear(orderedDates, current.getYear()); do { nextInSameMonth = nextBothInSameMonth; nextBothInSameMonth = DateUtils.sameMonth(next, overNext); if (previousYear != current.getYear()) { buffer.append("am "); } buffer.append(current.getDayOfMonth()); buffer.append('.'); if (!nextInSameMonth) { buffer.append(' '); buffer.append(MONTH_NAMES[current.getMonthOfYear()]); } if (!DateUtils.sameYear(current, next)) { buffer.append(' '); buffer.append(current.getYear()); if (next != null) { if (!DateUtils.sameYear(next, orderedDates.last())) { buffer.append(", "); } else { buffer.append(" und ebenfalls "); if (!signum) { buffer.append("nicht "); } } } if (next != null) { lastMonthOfYear = DateUtils.lastMonthForYear(orderedDates, next.getYear()); } } else if (next != null) { if (nextInSameMonth && nextBothInSameMonth || !nextInSameMonth && next.getMonthOfYear() != lastMonthOfYear) { buffer.append(", "); } else { buffer.append(" und "); } } previousYear = current.getYear(); current = next; next = overNext; overNext = datesIterator.hasNext() ? datesIterator.next() : null; } while (current != null); }
From source file:org.goobi.production.model.bibliography.course.CourseToGerman.java
License:Open Source License
/** * The method appendDate() writes a date to the buffer. * * @param buffer/*from w w w . j a va 2s . c om*/ * Buffer to write to * @param date * Date to write */ private static void appendDate(StringBuilder buffer, LocalDate date) { buffer.append(date.getDayOfMonth()); buffer.append(". "); buffer.append(MONTH_NAMES[date.getMonthOfYear()]); buffer.append(' '); buffer.append(date.getYear()); return; }
From source file:org.gravidence.gravifon.util.DateTimeUtils.java
License:Open Source License
/** * Converts local date object to array of date fields.<p> * Resulting array content is as follows: <code>[yyyy,MM,dd]</code>. * /* w w w . j ava 2s. co m*/ * @param value date object * @return array of date fields */ public static int[] localDateToArray(LocalDate value) { int[] result; if (value == null) { result = null; } else { result = new int[3]; result[0] = value.getYear(); result[1] = value.getMonthOfYear(); result[2] = value.getDayOfMonth(); } return result; }
From source file:org.jadira.usertype.dateandtime.joda.AbstractMultiColumnDateMidnight.java
License:Apache License
@Override protected DateMidnight fromConvertedColumns(Object[] convertedColumns) { LocalDate datePart = (LocalDate) convertedColumns[0]; DateTimeZoneWithOffset offset = (DateTimeZoneWithOffset) convertedColumns[1]; final DateMidnight result; if (datePart == null) { result = null;//from w w w. jav a 2 s .co m } else { result = new DateMidnight(datePart.getYear(), datePart.getMonthOfYear(), datePart.getDayOfMonth(), offset.getStandardDateTimeZone()); } // Handling DST rollover if (datePart != null && offset.getOffsetDateTimeZone() != null && offset.getStandardDateTimeZone() .getOffset(result) > offset.getOffsetDateTimeZone().getOffset(result)) { return new DateMidnight(datePart.getYear(), datePart.getMonthOfYear(), datePart.getDayOfMonth(), offset.getOffsetDateTimeZone()); } return result; }
From source file:org.jpmml.evaluator.FieldValue.java
License:Open Source License
public LocalDateTime asLocalDateTime() { Object value = getValue();//from w w w. j ava 2 s .c om if (value instanceof LocalDate) { LocalDate instant = (LocalDate) value; return new LocalDateTime(instant.getYear(), instant.getMonthOfYear(), instant.getDayOfMonth(), 0, 0, 0); } else if (value instanceof LocalDateTime) { return (LocalDateTime) value; } throw new TypeCheckException(DataType.DATE_TIME, value); }
From source file:org.jpmml.evaluator.SecondsSinceDate.java
License:Open Source License
public SecondsSinceDate(LocalDate epoch, LocalDateTime dateTime) { setEpoch(epoch);/*from w w w . j a v a 2 s . c om*/ // Have to have the same set of fields LocalDateTime epochDateTime = new LocalDateTime(epoch.getYear(), epoch.getMonthOfYear(), epoch.getDayOfMonth(), 0, 0, 0); setSeconds(Seconds.secondsBetween(epochDateTime, dateTime)); }
From source file:org.jruby.ext.date.RubyDate.java
License:LGPL
private static DateTime todayDate(final ThreadContext context, final Chronology chrono) { org.joda.time.LocalDate today = new org.joda.time.LocalDate(RubyTime.getLocalTimeZone(context.runtime)); return new DateTime(today.getYear(), today.getMonthOfYear(), today.getDayOfMonth(), 0, 0, chrono); }
From source file:org.jtotus.gui.graph.GraphPrinter.java
License:Open Source License
private Day localDateToDay(LocalDate date) { Day tmpDay = new Day(date.getDayOfMonth(), date.getMonthOfYear(), date.getYear()); return tmpDay; }