List of usage examples for org.joda.time MutableDateTime setYear
public void setYear(final int year)
From source file:Bootstrap.java
License:Open Source License
public void doJob() { if (Play.mode == Play.Mode.DEV) { //BigTable.deleteAll(); // BigTableR.deleteAll(); ///*from w ww . j av a2s.c o m*/ Invoice.deleteAll(); Customer.deleteAll(); Employee.deleteAll(); User.deleteAll(); Fixtures.load("test-datas.yml"); int maxEntries = 2500; int maxEntriesR = 500; if (BigTable.count() == 0) { Logger.info("Creating " + maxEntries + " entries for testing"); BigTable bigTable; // Create an enty in the past, so that AsyncBlotter can fetch the updated rows MutableDateTime aDate = new MutableDateTime(); aDate.setMonthOfYear(1); aDate.setYear(2010); for (int i = 0; i < maxEntries; i++) { bigTable = new BigTable(); bigTable.variable01 = Math.random() * 100; bigTable.variable02 = Math.random() * 100; bigTable.lastUpdated = aDate.toDate(); if (i % 100 == 0) { aDate.addDays(1); Logger.info("Created " + i + " entries" + aDate.toString()); } bigTable.save(); } } if (BigTableR.count() == 0) { Logger.info("Creating " + maxEntriesR + " entries for BigTableR"); BigTableR bigTableR; int j = 0; String locCurs = "Localisation #0"; String segCurs = "Segment #0"; String perCurs = "Period #0"; for (int i = 0; i < maxEntriesR; i++) { bigTableR = new BigTableR(); bigTableR.difference = Math.random(); bigTableR.evolution = Math.random() * 10; bigTableR.localisation = locCurs; bigTableR.segment = segCurs; bigTableR.period = perCurs; bigTableR.indicator = new StringBuffer("Indicator #").append(i).toString(); bigTableR.product = new Long(10 * i); if (i % 100 == 0) { Logger.info("Created " + i + " entries"); locCurs = new StringBuffer("Localisation ").append(j).toString(); segCurs = new StringBuffer("Segment #").append(j).toString(); perCurs = new StringBuffer("Period #").append(j).toString(); j++; } bigTableR.save(); } } } }
From source file:com.edlogics.ElrcApplication.java
License:Open Source License
/** * Bean to hold the system maintenance date time. Defaults to a far future date time. * * @return/*from w w w . j a va2 s . co m*/ */ @Bean public MutableDateTime maintenanceDateTime() { MutableDateTime farFuture = MutableDateTime.now(DateTimeZone.forID(elrcTimezone)); // Set to year 9999 to make easy to check for far future value // There is no easy way to do a max Date with Joda time so this is the workaround farFuture.setYear(9999); return farFuture; }
From source file:com.foundationdb.server.types.mcompat.mfuncs.MWeek.java
License:Open Source License
private static int getMode1346(MutableDateTime cal, int yr, int mo, int da, int firstDay, int lowestVal) { cal.setYear(yr); cal.setMonthOfYear(1);//from www . j ava2 s . com 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; } }
From source file:com.foundationdb.server.types.mcompat.mfuncs.MWeek.java
License:Open Source License
private static int getMode0257(MutableDateTime cal, int yr, int mo, int da, int firstDay, int lowestVal) { cal.setYear(yr); cal.setMonthOfYear(1);/*from www. j a va2 s. c o m*/ 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; }
From source file:com.foundationdb.server.types.mcompat.mfuncs.MYearWeek.java
License:Open Source License
private static int getMode1346(MutableDateTime cal, int yr, int mo, int da, int firstDay, int lowestVal) { cal.setYear(yr); cal.setMonthOfYear(1);/* ww w. j a v a2 s.c o m*/ 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; } }
From source file:com.foundationdb.server.types.mcompat.mfuncs.MYearWeek.java
License:Open Source License
private static int getMode0257(MutableDateTime cal, int yr, int mo, int da, int firstDay, int lowestVal) { cal.setYear(yr); cal.setMonthOfYear(1);/* www . ja v a 2 s . c o m*/ 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; }
From source file:com.foundationdb.server.types.texpressions.DateTimeField.java
License:Open Source License
/** * to be used in X and x// w w w . j a v a2 s. c o m * @param cal * @param yr * @param mo * @param da * @param firstDay: the first day of week * @return the year for this week, could be the same as yr or different * , depending on the first day of year */ private static int getYear(MutableDateTime cal, int yr, int mo, int da, int firstDay) { if (mo > 1 || da > 7) return yr; cal.setYear(yr); cal.setMonthOfYear(1); cal.setDayOfMonth(1); int firstD = 1; while (cal.getDayOfWeek() != firstDay) cal.setDayOfMonth(++firstD); // reset cal cal.setYear(yr); cal.setMonthOfYear(mo); cal.setDayOfMonth(da); if (da < firstD) return yr - 1; else return yr; }
From source file:com.foundationdb.server.types.texpressions.DateTimeField.java
License:Open Source License
/** * to be used in V, v, U and u//from w w w. ja v a 2s .co m * @param cal * @param yr * @param mo * @param da * @param firstDay * @param lowestIs0: whether the lowest value could be zero or not * @return the week for this date, if the lowest value is not supposed to be zero, then it returns that * the number of the last week in the previous year */ private static int getWeek(MutableDateTime cal, int yr, int mo, int da, int firstDay, boolean lowestIs0) { 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(); int result; if (dayOfYear < firstD) result = (lowestIs0 ? 0 : getWeek(cal, yr - 1, 12, 31, firstDay, lowestIs0)); else result = (dayOfYear - firstD) / 7 + 1; // reset cal cal.setYear(yr); cal.setMonthOfYear(mo); cal.setDayOfMonth(da); return result; }
From source file:com.tmathmeyer.sentinel.models.data.Commitment.java
License:Open Source License
@Override public void setTime(DateTime newTime) { MutableDateTime mdt = new MutableDateTime(this.duedate); mdt.setDayOfYear(newTime.getDayOfYear()); mdt.setYear(newTime.getYear()); this.duedate = mdt.toDate(); }
From source file:com.tmathmeyer.sentinel.ui.navigation.GoToPanel.java
License:Open Source License
/** * Parses the input to the goTo field to ensure proper formatting and handle * syntax errors//w ww. ja va2s .c o m * * @param text string to parse */ public void parseGoto(String text) { DateTime dt; boolean isValidYear = true; try { dt = gotoField.parseDateTime(text); if (dt.getYear() < 1900 || dt.getYear() > 2100) { isValidYear = false; dt = null; } } catch (IllegalArgumentException illArg) { try { MutableDateTime mdt = gotoFieldShort.parseMutableDateTime(text); mdt.setYear(currentDate.getYear()); // this format does not // provide years. add it dt = mdt.toDateTime(); } catch (IllegalArgumentException varArg) { dt = null; } } if (dt != null) { MainPanel.getInstance().display(dt); MainPanel.getInstance().refreshView(); gotoErrorText.setText(" "); } else { if (isValidYear) gotoErrorText.setText("* Use format: mm/dd/yyyy"); else gotoErrorText.setText("* Year out of range (1900-2100)"); } }