List of usage examples for org.joda.time DateTime toDateMidnight
@Deprecated
public DateMidnight toDateMidnight()
DateMidnight
using the same millis and chronology. From source file:br.com.caelum.vraptor.converter.jodatime.DateMidnightConverter.java
License:Open Source License
public DateMidnight convert(String value, Class<? extends DateMidnight> type, ResourceBundle bundle) { try {//from w ww.j a va2 s . c o m DateTime out = new LocaleBasedJodaTimeConverter(localization).convert(value, shortDate()); if (out == null) { return null; } return out.toDateMidnight(); } catch (Exception e) { throw new ConversionError(MessageFormat.format(bundle.getString("is_not_a_valid_datetime"), value)); } }
From source file:com.google.android.apps.paco.Experiment.java
License:Open Source License
@JsonIgnore DateMidnight getPeriodStart(DateTime now) { switch (((SignalSchedule) getSignalingMechanisms().get(0)).getEsmPeriodInDays()) { case SignalSchedule.ESM_PERIOD_DAY: return now.toDateMidnight(); case SignalSchedule.ESM_PERIOD_WEEK: return now.dayOfWeek().withMinimumValue().toDateMidnight(); case SignalSchedule.ESM_PERIOD_MONTH: return now.dayOfMonth().withMinimumValue().toDateMidnight(); default://from w ww .j a v a2 s .co m throw new IllegalStateException("Cannot get here."); } }
From source file:com.google.android.apps.paco.NonESMSignalGenerator.java
License:Open Source License
private DateTime scheduleMonthly(DateTime now) { DateTime nowMidnight = now.toDateMidnight().toDateTime(); if (schedule.getByDayOfMonth()) { int nowDOM = nowMidnight.getDayOfMonth(); if (nowDOM == schedule.getDayOfMonth()) { DateTime nextTimeToday = getNextTimeToday(now, nowMidnight); if (nextTimeToday != null) { return nextTimeToday; }// w ww .ja va 2 s .com } DateTime nextDay = getNextScheduleDay(nowMidnight.plusDays(1)); return getFirstScheduledTimeOnDay(nextDay); } else { DateTime nextDay = getNextScheduleDay(nowMidnight); if (nextDay.equals(nowMidnight)) { DateTime nextTimeToday = getNextTimeToday(now, nextDay); if (nextTimeToday != null) { return nextTimeToday; } nextDay = getNextScheduleDay(nowMidnight.plusDays(1)); return getFirstScheduledTimeOnDay(nextDay); } else { return getFirstScheduledTimeOnDay(nextDay); } } }
From source file:com.google.android.apps.paco.NonESMSignalGenerator.java
License:Open Source License
private DateTime scheduleWeekly(DateTime now) { DateTime nowMidnight = now.toDateMidnight().toDateTime(); int nowDow = nowMidnight.getDayOfWeek(); // joda starts Monday, I start Sunday Integer nowDowIndex = SignalSchedule.DAYS_OF_WEEK[nowDow == 7 ? 0 : nowDow]; // joda is 1 based, and starts on Monday. we are 0-based, Sunday-start if ((schedule.getWeekDaysScheduled() & nowDowIndex) == nowDowIndex) { DateTime nextTimeToday = getNextTimeToday(now, nowMidnight); if (nextTimeToday != null) { return nextTimeToday; }//from w w w. j av a2 s.c om } DateTime nextDay = getNextScheduleDay(nowMidnight.plusDays(1)); return getFirstScheduledTimeOnDay(nextDay); }
From source file:com.google.android.apps.paco.NonESMSignalGenerator.java
License:Open Source License
private DateTime scheduleDaily(DateTime now) { DateTime nowMidnight = now.toDateMidnight().toDateTime(); if (nextRepeatDaily(nowMidnight).equals(nowMidnight)) { DateTime nextTimeToday = getNextTimeToday(now, nowMidnight); if (nextTimeToday != null) { return nextTimeToday; }/*from www .j ava 2 s . c o m*/ } DateTime nextDay = getNextScheduleDay(nowMidnight.plusDays(1)); return getFirstScheduledTimeOnDay(nextDay); }
From source file:com.google.android.apps.paco.NonESMSignalGenerator.java
License:Open Source License
private DateTime scheduleWeekday(DateTime now) { DateTime nowMidnight = now.toDateMidnight().toDateTime(); if (nowMidnight.getDayOfWeek() < DateTimeConstants.SATURDAY) { // jodatime starts with Monday = 0 DateTime nextTimeToday = getNextTimeToday(now, nowMidnight); if (nextTimeToday != null) { return nextTimeToday; }//w w w. j ava 2s . com } DateTime nextDay = getNextScheduleDay(nowMidnight.plusDays(1)); return getFirstScheduledTimeOnDay(nextDay); }
From source file:com.google.android.apps.paco.TimeUtil.java
License:Open Source License
public static DateMidnight getMondayOfWeek(DateTime now) { DateMidnight mondayOfWeek = now.toDateMidnight(); int dow = mondayOfWeek.getDayOfWeek(); if (dow != DateTimeConstants.MONDAY) { mondayOfWeek = mondayOfWeek.minusDays(dow - 1); }/* ww w . ja v a 2 s . co m*/ return mondayOfWeek; }
From source file:com.kopysoft.chronos.adapter.clock.PayPeriodAdapterList.java
License:Open Source License
public DurationHolder getTime(WeekendOverride sat, WeekendOverride sun) { DurationHolder durHolder = new DurationHolder(); for (DateTime date : gPunchesByDay.getDays()) { if (date.getDayOfWeek() == DateTimeConstants.SATURDAY && sat != WeekendOverride.NONE) { Duration temp = getTime(gPunchesByDay.getPunchPair(date)); durHolder.addSaturdayPay(date.toDateMidnight(), temp); } else if (date.getDayOfWeek() == DateTimeConstants.SUNDAY && sun != WeekendOverride.NONE) { Duration temp = getTime(gPunchesByDay.getPunchPair(date)); durHolder.addSundayPay(date.toDateMidnight(), temp); } else {// w ww.j a v a 2 s. c om Duration temp = getTime(gPunchesByDay.getPunchPair(date)); durHolder.addNormalPay(date.toDateMidnight(), temp); } } return durHolder; }
From source file:com.kopysoft.chronos.views.ClockFragments.Today.DatePairView.java
License:Open Source License
public DatePairView(SherlockActivity prnt, List<Punch> punches, DateTime date) { super(prnt.getApplicationContext()); gDate = date;// ww w . j a v a 2 s .c om parent = prnt; if (enableLog) { Log.d(TAG, "Entry 2"); for (Punch p : punches) { Log.d(TAG, "init punch: " + p); } Log.d(TAG, "init date: " + date); } Chronos chrono = new Chronos(parent); thisJob = chrono.getAllJobs().get(0); if (enableLog) Log.d(TAG, "Entry 2 Pay: " + thisJob.getPayRate()); chrono.close(); adapter = new TodayAdapterPair(parent, punches, thisJob); if (adapter.getTime(true).getMillis() < 0 && date.toDateMidnight().isEqual(new DateMidnight())) { mHandler.postDelayed(mUpdateTimeTask, 100); } else { mHandler.removeCallbacks(mUpdateTimeTask); } createUI(adapter, thisJob); }
From source file:com.pacoapp.paco.shared.scheduling.NonESMSignalGenerator.java
License:Open Source License
private DateTime scheduleWeekly(DateTime now) { DateTime nowMidnight = now.toDateMidnight().toDateTime(); int nowDow = nowMidnight.getDayOfWeek(); // joda starts Monday, I start Sunday Integer nowDowIndex = Schedule.DAYS_OF_WEEK[nowDow == 7 ? 0 : nowDow]; // joda is 1 based, and starts on Monday. we are 0-based, Sunday-start if ((schedule.getWeekDaysScheduled() & nowDowIndex) == nowDowIndex) { DateTime nextTimeToday = getNextTimeToday(now, nowMidnight); if (nextTimeToday != null) { return nextTimeToday; }// w w w. j a v a 2 s . c o m } DateTime nextDay = getNextScheduleDay(nowMidnight.plusDays(1)); return getFirstScheduledTimeOnDay(nextDay); }