List of usage examples for org.joda.time DateTimeField getMaximumValue
public abstract int getMaximumValue(ReadablePartial instant);
From source file:de.raion.xmppbot.command.DilbertCommand.java
License:Apache License
private int getDaysInMonth(int year, int month) { Chronology chrono = ISOChronology.getInstance(); DateTimeField dayField = chrono.dayOfMonth(); LocalDate monthDate = new LocalDate(year, month, 1); return dayField.getMaximumValue(monthDate); }
From source file:ee.ut.soras.ajavtV2.mudel.ajavaljend.arvutus.SemLeidmiseAbimeetodid.java
License:Open Source License
/** * Tagastab antud kalendriv2ljaga seotud ekstreemum (min v6i max) v22rtuse; */// w ww. j ava 2 s.co m public static int getLocalDateTimeFieldExtremum(BaseLocal partial, DateTimeFieldType type, boolean getMax) { DateTimeField field = type.getField(partial.getChronology()); return (getMax) ? (field.getMaximumValue(partial)) : (field.getMinimumValue(partial)); }
From source file:org.finra.datagenerator.engine.scxml.tags.boundary.BoundaryDate.java
License:Apache License
/** * Given a year, month, and day, find the number of occurrences of that day in the month * * @param year the year/* w w w.j ava 2 s.co m*/ * @param month the month * @param day the day * @return the number of occurrences of the day in the month */ public int numOccurrences(int year, int month, int day) { DateTimeFormatter parser = ISODateTimeFormat.date(); DateTime date = parser.parseDateTime(year + "-" + month + "-" + "01"); Calendar cal = Calendar.getInstance(); cal.setTime(date.toDate()); GregorianChronology calendar = GregorianChronology.getInstance(); DateTimeField field = calendar.dayOfMonth(); int days = 0; int count = 0; int num = field.getMaximumValue(new LocalDate(year, month, day, calendar)); while (days < num) { if (cal.get(Calendar.DAY_OF_WEEK) == day) { count++; } date = date.plusDays(1); cal.setTime(date.toDate()); days++; } return count; }