List of usage examples for org.joda.time DateTime withMinuteOfHour
public DateTime withMinuteOfHour(int minute)
From source file:com.arpnetworking.kairosdb.aggregators.MovingWindowAggregator.java
License:Apache License
/** * For YEARS, MONTHS, WEEKS, DAYS: Computes the timestamp of the first * millisecond of the day of the timestamp. For HOURS, Computes the timestamp of * the first millisecond of the hour of the timestamp. For MINUTES, Computes the * timestamp of the first millisecond of the minute of the timestamp. For * SECONDS, Computes the timestamp of the first millisecond of the second of the * timestamp. For MILLISECONDS, returns the timestamp * * @param timestamp Timestamp in milliseconds to use as a basis for range alignment * @return timestamp aligned to the configured sampling unit *//* w w w.j a v a2s . co m*/ @SuppressWarnings("fallthrough") @SuppressFBWarnings("SF_SWITCH_FALLTHROUGH") private long alignRangeBoundary(final long timestamp) { DateTime dt = new DateTime(timestamp, _timeZone); final TimeUnit tu = m_sampling.getUnit(); switch (tu) { case YEARS: dt = dt.withDayOfYear(1).withMillisOfDay(0); break; case MONTHS: dt = dt.withDayOfMonth(1).withMillisOfDay(0); break; case WEEKS: dt = dt.withDayOfWeek(1).withMillisOfDay(0); break; case DAYS: dt = dt.withHourOfDay(0); case HOURS: dt = dt.withMinuteOfHour(0); case MINUTES: dt = dt.withSecondOfMinute(0); case SECONDS: default: dt = dt.withMillisOfSecond(0); break; } return dt.getMillis(); }
From source file:com.boha.monitor.utilx.ListUtil.java
public static ResponseDTO getProjectStatusData(EntityManager em, Integer projectID, int days) throws DataException { long s = System.currentTimeMillis(); if (days == 0) { days = 30;// ww w . ja va2s.c om } ResponseDTO resp = new ResponseDTO(); try { Project p = em.find(Project.class, projectID); ProjectDTO project = new ProjectDTO(p); DateTime now = new DateTime(); DateTime then = now.minusDays(days); then = then.withHourOfDay(0); then = then.withMinuteOfHour(0); then = then.withSecondOfMinute(0); project.setProjectTaskList( ListUtil.getProjectStatus(em, projectID, then.toDate(), now.toDate()).getProjectTaskList()); project.setPhotoUploadList( getPhotosByProject(em, projectID, then.toDate(), now.toDate()).getPhotoUploadList()); resp.setProjectList(new ArrayList<>()); resp.getProjectList().add(project); long e = System.currentTimeMillis(); log.log(Level.INFO, "############---------- project data retrieved: {0} seconds", Elapsed.getElapsed(s, e)); } catch (OutOfMemoryError e) { log.log(Level.SEVERE, "Failed", e); throw new DataException("Failed to get project data: OUT OF MEMORY!\n"); } return resp; }
From source file:com.github.dbourdette.otto.source.TimeFrame.java
License:Apache License
private DateTime fiveMinutes(DateTime dateTime) { dateTime = dateTime.withMillisOfSecond(0); dateTime = dateTime.withSecondOfMinute(0); int minutes = dateTime.getMinuteOfHour(); return dateTime.withMinuteOfHour(minutes / 5 * 5); }
From source file:com.github.dbourdette.otto.source.TimeFrame.java
License:Apache License
private DateTime thirtyMinutes(DateTime dateTime) { dateTime = dateTime.withMillisOfSecond(0); dateTime = dateTime.withSecondOfMinute(0); if (dateTime.getMinuteOfHour() < 30) { return dateTime.withMinuteOfHour(0); } else {/*from w w w . j a v a 2 s.com*/ return dateTime.withMinuteOfHour(30); } }
From source file:com.github.dbourdette.otto.source.TimeFrame.java
License:Apache License
private DateTime oneHour(DateTime dateTime) { dateTime = dateTime.withMillisOfSecond(0); dateTime = dateTime.withSecondOfMinute(0); return dateTime.withMinuteOfHour(0); }
From source file:com.github.dbourdette.otto.source.TimeFrame.java
License:Apache License
private DateTime twelveHours(DateTime dateTime) { dateTime = dateTime.withMillisOfSecond(0); dateTime = dateTime.withSecondOfMinute(0); dateTime = dateTime.withMinuteOfHour(0); if (dateTime.getHourOfDay() < 12) { return dateTime.withHourOfDay(0); } else {/*ww w.ja v a 2s . c o m*/ return dateTime.withHourOfDay(12); } }
From source file:com.github.dbourdette.otto.source.TimeFrame.java
License:Apache License
private DateTime oneDay(DateTime dateTime) { dateTime = dateTime.withMillisOfSecond(0); dateTime = dateTime.withSecondOfMinute(0); dateTime = dateTime.withMinuteOfHour(0); return dateTime.withHourOfDay(0); }
From source file:com.jay.pea.mhealthapp2.presenter.NewMedication.java
License:Open Source License
/** * method to set up alert times//from w w w. j a v a 2 s .c om * * @param pos */ private void setUpAlertTimes(int pos) { //clear alert text fields prior to setting up alert times alertArray = new TextView[] { alert1, alert2, alert3, alert4, alert5, alert6 }; for (int i = 0; i < alertArray.length; i++) { final TextView alert = alertArray[i]; alert.setText(""); alert.setKeyListener((KeyListener) alert.getTag()); } //fall through used (no break statements) to set alerts depending on freq requested by user DateTime now = new DateTime().now(); DateTime today = now.withMinuteOfHour(0).withSecondOfMinute(0); DateTime[] times2 = new DateTime[] { today.withHourOfDay(20), today.withHourOfDay(14), today.withHourOfDay(12), today.withHourOfDay(11), today.withHourOfDay(10) }; DateTime[] times3 = new DateTime[] { today.withHourOfDay(20), today.withHourOfDay(16), today.withHourOfDay(14), today.withHourOfDay(12) }; DateTime[] times4 = new DateTime[] { today.withHourOfDay(20), today.withHourOfDay(17), today.withHourOfDay(14) }; DateTime[] times5 = new DateTime[] { today.withHourOfDay(20), today.withHourOfDay(17) }; switch (pos) { case 5: alert6.setText(today.withHourOfDay(20).toString(dtfTime)); case 4: alert5.setText(times5[pos - 4].toString(dtfTime)); case 3: alert4.setText(times4[pos - 3].toString(dtfTime)); case 2: alert3.setText(times3[pos - 2].toString(dtfTime)); case 1: alert2.setText(times2[pos - 1].toString(dtfTime)); case 0: alert1.setText(today.withHourOfDay(8).toString(dtfTime)); } for (int i = 0; i < alertArray.length; i++) { final TextView alert = alertArray[i]; if (alert.getText().toString().isEmpty()) { alert.setFocusable(false); alert.setFocusableInTouchMode(false); alert.setClickable(false); Log.d(TAG, alert.getText().toString().equals("") + ""); } } }
From source file:com.kopysoft.chronos.activities.fragment.JobFragment.java
License:Open Source License
@Override public void onPause() { super.onPause(); Chronos chrono = new Chronos(getActivity()); Job thisJob = chrono.getAllJobs().get(0); /*//from w w w . j a v a 2 s. c om EditText dataPayRate; Spinner dataPayPeriodLength; DatePicker dataStartOfPayPeriod; TimePicker dataTimePicker; */ Log.d(TAG, "onPause()"); dataPayRate.clearFocus(); dataPayPeriodLength.clearFocus(); dataStartOfPayPeriod.clearFocus(); dataTimePicker.clearFocus(); try { thisJob.setPayRate(Float.parseFloat(dataPayRate.getText().toString())); Log.d(TAG, "Pay Rate: " + thisJob.getPayRate()); } catch (NumberFormatException e) { Toast.makeText(getActivity(), "Pay Rate format incorrect", Toast.LENGTH_SHORT).show(); } PayPeriodDuration duration = PayPeriodDuration.values()[dataPayPeriodLength.getSelectedItemPosition()]; thisJob.setDuration(duration); DateTime newTime = thisJob.getStartOfPayPeriod(); newTime = newTime.withDayOfMonth(dataStartOfPayPeriod.getDayOfMonth()); newTime = newTime.withMonthOfYear(dataStartOfPayPeriod.getMonth() + 1); newTime = newTime.withYear(dataStartOfPayPeriod.getYear()); newTime = newTime.withHourOfDay(dataTimePicker.getCurrentHour()); newTime = newTime.withMinuteOfHour(dataTimePicker.getCurrentMinute()); thisJob.setStartOfPayPeriod(newTime); chrono.updateJob(thisJob); chrono.close(); }
From source file:com.model.CalendarViewModel.java
License:Open Source License
public DateTime addIntegerHoursMinutes(DateTime time, int hoursMinutes) { int count = 0; while (hoursMinutes >= 60) { count++;/* ww w . ja v a 2 s . co m*/ hoursMinutes -= 60; } time = time.withHourOfDay(count); time = time.withMinuteOfHour(hoursMinutes); return time; }