Java Code Examples for org.joda.time.MutableDateTime#getDayOfWeek()
The following examples show how to use
org.joda.time.MutableDateTime#getDayOfWeek() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: MYearWeek.java From sql-layer with GNU Affero General Public License v3.0 | 6 votes |
private static int getMode0257(MutableDateTime cal, int yr, int mo, int da, int firstDay, int lowestVal) { cal.setYear(yr); cal.setMonthOfYear(1); cal.setDayOfMonth(1); int firstD = 1; while (cal.getDayOfWeek() != firstDay) cal.setDayOfMonth(++firstD); cal.setYear(yr); cal.setMonthOfYear(mo); cal.setDayOfMonth(da); int dayOfYear = cal.getDayOfYear(); if (dayOfYear < firstD) return modes[lowestVal].getYearWeek(cal, yr - 1, 12, 31); else return yr * 100 + (dayOfYear - firstD) / 7 +1; }
Example 2
Source File: MWeek.java From sql-layer with GNU Affero General Public License v3.0 | 6 votes |
private static int getMode0257(MutableDateTime cal, int yr, int mo, int da, int firstDay, int lowestVal) { cal.setYear(yr); cal.setMonthOfYear(1); cal.setDayOfMonth(1); int firstD = 1; while (cal.getDayOfWeek() != firstDay) cal.setDayOfMonth(++firstD); cal.setYear(yr); cal.setMonthOfYear(mo); cal.setDayOfMonth(da); int dayOfYear = cal.getDayOfYear(); if (dayOfYear < firstD) return modes[lowestVal].getWeek(cal, yr-1, 12, 31); else return (dayOfYear - firstD) / 7 +1; }
Example 3
Source File: MYearWeek.java From sql-layer with GNU Affero General Public License v3.0 | 5 votes |
private static int getMode1346(MutableDateTime cal, int yr, int mo, int da, int firstDay, int lowestVal) { cal.setYear(yr); cal.setMonthOfYear(1); cal.setDayOfMonth(1); int firstD = 1; while (cal.getDayOfWeek() != firstDay) cal.setDayOfMonth(++firstD); cal.setYear(yr); cal.setMonthOfYear(mo); cal.setDayOfMonth(da); int week = cal.getDayOfYear() - (firstD +1 ); // Sun/Mon if (firstD < 4) { if (week < 0) return modes[lowestVal].getYearWeek(cal, yr - 1, 12, 31); else return yr * 100 + week / 7 + 1; } else { if (week < 0) return yr * 100 + 1; else return yr * 100 + week / 7 + 2; } }
Example 4
Source File: MWeek.java From sql-layer with GNU Affero General Public License v3.0 | 5 votes |
private static int getMode1346(MutableDateTime cal, int yr, int mo, int da, int firstDay, int lowestVal) { cal.setYear(yr); cal.setMonthOfYear(1); cal.setDayOfMonth(1); int firstD = 1; while (cal.getDayOfWeek() != firstDay) cal.setDayOfMonth(++firstD); cal.setYear(yr); cal.setMonthOfYear(mo); cal.setDayOfMonth(da); int week = cal.getDayOfYear() - (firstD +1 ); // Sun/Mon if (firstD < 4) { if (week < 0) return modes[lowestVal].getWeek(cal, yr-1, 12, 31); else return week / 7 + 1; } else { if (week < 0) return 1; else return week / 7 + 2; } }
Example 5
Source File: TestTextFields.java From astor with GNU General Public License v2.0 | 5 votes |
public void testWeekdayNames() { DateTimeFormatter printer = DateTimeFormat.forPattern("EEEE"); for (int i=0; i<ZONES.length; i++) { MutableDateTime mdt = new MutableDateTime(2004, 1, 1, 1, 20, 30, 40, ZONES[i]); for (int day=1; day<=366; day++) { mdt.setDayOfYear(day); int weekday = mdt.getDayOfWeek(); String weekdayText = printer.print(mdt); assertEquals(WEEKDAYS[weekday], weekdayText); } } }
Example 6
Source File: TestTextFields.java From astor with GNU General Public License v2.0 | 5 votes |
public void testWeekdayNames() { DateTimeFormatter printer = DateTimeFormat.forPattern("EEEE"); for (int i=0; i<ZONES.length; i++) { MutableDateTime mdt = new MutableDateTime(2004, 1, 1, 1, 20, 30, 40, ZONES[i]); for (int day=1; day<=366; day++) { mdt.setDayOfYear(day); int weekday = mdt.getDayOfWeek(); String weekdayText = printer.print(mdt); assertEquals(WEEKDAYS[weekday], weekdayText); } } }