List of usage examples for org.joda.time DateTime getMinuteOfHour
public int getMinuteOfHour()
From source file:pt.utl.ist.codeGenerator.database.WrittenTestsRoomManager.java
License:Open Source License
public DateTime getNextDateTime(final ExecutionSemester executionPeriod) { EvaluationRoomManager evaluationRoomManager = evaluationRoomManagerMap.get(executionPeriod); if (evaluationRoomManager == null) { evaluationRoomManager = new EvaluationRoomManager( executionPeriod.getBeginDateYearMonthDay().plusMonths(1).toDateTimeAtMidnight(), executionPeriod.getEndDateYearMonthDay().minusDays(31).toDateTimeAtMidnight(), 120, this); evaluationRoomManagerMap.put(executionPeriod, evaluationRoomManager); }/* w w w . j av a 2 s. c om*/ DateTime dateTime; Space oldRoom; do { dateTime = evaluationRoomManager.getNextDateTime(); oldRoom = evaluationRoomManager.getNextOldRoom(); } while (SpaceUtils.isFree(oldRoom, dateTime.toYearMonthDay(), dateTime.plusMinutes(120).toYearMonthDay(), new HourMinuteSecond(dateTime.getHourOfDay(), dateTime.getMinuteOfHour(), dateTime.getSecondOfMinute()), dateTime.plusMinutes(120).getHourOfDay() == 0 ? new HourMinuteSecond(dateTime.plusMinutes(119).getHourOfDay(), dateTime.plusMinutes(119).getMinuteOfHour(), dateTime.plusMinutes(119).getSecondOfMinute()) : new HourMinuteSecond(dateTime.plusMinutes(120).getHourOfDay(), dateTime.plusMinutes(120).getMinuteOfHour(), dateTime.plusMinutes(120).getSecondOfMinute()), new DiaSemana(dateTime.getDayOfWeek() + 1), FrequencyType.DAILY, Boolean.TRUE, Boolean.TRUE)); return dateTime; }
From source file:rapture.event.generator.EventGenerator.java
License:Open Source License
private static void generatePeriodic(List<String> ret, DateTime dt, boolean periodic) { // We guarantee that each call to this function, cal will be advanced a // minute at least int dayOfWeek = dt.getDayOfWeek(); if (periodic) { checkAdd(dayOfWeek, dt.getMinuteOfHour(), minuteChecks, "minutes", "/time", ret); if (dt.getMinuteOfHour() == 0) { checkAdd(dayOfWeek, dt.getHourOfDay(), hourChecks, "hours", "/time", ret); if (dt.getHourOfDay() == 0) { ret.add("/time/days" + dt.getDayOfMonth()); if (dt.getDayOfMonth() == 1) { ret.add("/time/months" + dt.getMonthOfYear()); }/* ww w . j a v a2s.c o m*/ } } } // We construct, for each supported timezone, // timezone/daily/[timezone]/hour/minute // timezone/weekend/ (if a weekend) // timezone/weekeday/ (if a weekday) // timezone/day // So initially create the end point for each timezone, then push it out // We assume dt is in UT (but does this matter?) for (Map.Entry<String, DateTimeZone> zoneEntry : timeZones.entrySet()) { DateTime dtLocal = dt.withZone(zoneEntry.getValue()); String convertedZone = getConvertedTimeZone(zoneEntry.getKey()); int localDow = dtLocal.getDayOfWeek(); String endField = hmFormat.print(dtLocal); ret.add(String.format("/timezone/daily/%s/%s", convertedZone, endField)); ret.add(String.format("/timezone/%s/%s/%s", isWeekend(localDow) ? "weekend" : "weekday", convertedZone, endField)); ret.add(String.format("/timezone/%s/%s/%s", getDOWName(localDow), convertedZone, endField)); } }
From source file:se.toxbee.sleepfighter.activity.AlarmActivity.java
License:Open Source License
public String getCurrentTime() { DateTime time = new DateTime(); return StringUtils.joinTime(time.getHourOfDay(), time.getMinuteOfHour()); }
From source file:singlejartest.Explorer30or5MinRepeat.java
License:Open Source License
protected static DateTime calcEndBar() { // During weekend set end bar to last trading bar of previous Friday DateTime timeStamp = new DateTime(), roundedEnd = new DateTime(timeStamp.getYear(), timeStamp.getMonthOfYear(), timeStamp.getDayOfMonth(), timeStamp.getHourOfDay(), timeStamp.getMinuteOfHour() % 5 == 0 ? timeStamp.getMinuteOfHour() : (timeStamp.getMinuteOfHour() / 5) * 5, 0, 0), result = new DateTime(roundedEnd); if ((roundedEnd.getDayOfWeek() == DateTimeConstants.FRIDAY && roundedEnd.getHourOfDay() > 22) || roundedEnd.getDayOfWeek() == DateTimeConstants.SATURDAY || (roundedEnd.getDayOfWeek() == DateTimeConstants.SUNDAY && roundedEnd.getHourOfDay() < 23)) { if (roundedEnd.getDayOfWeek() == DateTimeConstants.FRIDAY) result = new DateTime(roundedEnd.getYear(), roundedEnd.getMonthOfYear(), roundedEnd.getDayOfMonth(), 22, 30, 0, 0);/*from ww w .j a v a 2 s . co m*/ else if (roundedEnd.getDayOfWeek() == DateTimeConstants.SATURDAY) { DateTime friday = new DateTime(roundedEnd.minusDays(1)); result = new DateTime(friday.getYear(), friday.getMonthOfYear(), friday.getDayOfMonth(), 22, 30, 0, 0); } else if (roundedEnd.getDayOfWeek() == DateTimeConstants.SUNDAY && roundedEnd.getHourOfDay() < 23) { DateTime friday = new DateTime(roundedEnd.minusDays(2)); result = new DateTime(friday.getYear(), friday.getMonthOfYear(), friday.getDayOfMonth(), 22, 30, 0, 0); } } return result; }
From source file:singlejartest.Strategy30MinRepeat.java
License:Open Source License
protected static DateTime calcEndBar() { // During weekend set end bar to last trading bar of previous Friday DateTime timeStamp = new DateTime(), roundedEnd = new DateTime(timeStamp.getYear(), timeStamp.getMonthOfYear(), timeStamp.getDayOfMonth(), timeStamp.getHourOfDay(), timeStamp.getMinuteOfHour() < 30 ? 0 : 30, 0, 0), result = new DateTime(roundedEnd); if ((roundedEnd.getDayOfWeek() == DateTimeConstants.FRIDAY && roundedEnd.getHourOfDay() > 22) || roundedEnd.getDayOfWeek() == DateTimeConstants.SATURDAY || (roundedEnd.getDayOfWeek() == DateTimeConstants.SUNDAY && roundedEnd.getHourOfDay() < 23)) { if (roundedEnd.getDayOfWeek() == DateTimeConstants.FRIDAY) result = new DateTime(roundedEnd.getYear(), roundedEnd.getMonthOfYear(), roundedEnd.getDayOfMonth(), 22, 30, 0, 0);//from w ww .java2 s . c om else if (roundedEnd.getDayOfWeek() == DateTimeConstants.SATURDAY) { DateTime friday = new DateTime(roundedEnd.minusDays(1)); result = new DateTime(friday.getYear(), friday.getMonthOfYear(), friday.getDayOfMonth(), 22, 30, 0, 0); } else if (roundedEnd.getDayOfWeek() == DateTimeConstants.SUNDAY && roundedEnd.getHourOfDay() < 23) { DateTime friday = new DateTime(roundedEnd.minusDays(2)); result = new DateTime(friday.getYear(), friday.getMonthOfYear(), friday.getDayOfMonth(), 22, 30, 0, 0); } } return result; }
From source file:stroom.pipeline.server.writer.PathCreator.java
License:Apache License
public static String replaceTimeVars(String path) { // Replace some of the path elements with system variables. final DateTime dateTime = new DateTime(DateTimeZone.UTC); path = replace(path, "year", dateTime.getYear(), 4); path = replace(path, "month", dateTime.getMonthOfYear(), 2); path = replace(path, "day", dateTime.getDayOfMonth(), 2); path = replace(path, "hour", dateTime.getHourOfDay(), 2); path = replace(path, "minute", dateTime.getMinuteOfHour(), 2); path = replace(path, "second", dateTime.getSecondOfMinute(), 2); path = replace(path, "millis", dateTime.getMillisOfSecond(), 3); path = replace(path, "ms", dateTime.getMillis(), 0); return path;/*from w w w .j ava 2s. c o m*/ }
From source file:test.sql.CustomerDataManager.java
License:Apache License
public String makeSubject() { // String sub = LINKAGE_SUBJECT_PREFIX + StressTester.randomString(8); DateTime now = new DateTime(); int year, month, day, hour, minute, second; year = now.year().get();/*from w w w.java 2 s . c o m*/ month = now.monthOfYear().get(); day = now.dayOfMonth().get(); hour = now.getHourOfDay(); minute = now.getMinuteOfHour(); second = now.getSecondOfMinute(); StringBuilder sb = new StringBuilder(); sb.append(LINKAGE_SUBJECT_PREFIX); sb.append(StressTester.randomString(8)); sb.append("_"); sb.append(Integer.toString(year)); if (month < 10) sb.append("0"); sb.append(Integer.toString(month)); if (day < 10) sb.append("0"); sb.append(Integer.toString(day)); sb.append("_"); if (hour < 10) sb.append("0"); sb.append(Integer.toString(hour)); if (minute < 10) sb.append("0"); sb.append(Integer.toString(minute)); if (second < 10) sb.append("0"); sb.append(Integer.toString(second)); return sb.toString(); }
From source file:test.sql.TrackingDataManager.java
License:Apache License
public String makeSubject() { String sub = LINKAGE_SUBJECT_PREFIX + StressTester.randomString(8); DateTime now = new DateTime(); int year, month, day, hour, minute, second; year = now.year().get();//w ww.j a v a 2 s . co m month = now.monthOfYear().get(); day = now.dayOfMonth().get(); hour = now.getHourOfDay(); minute = now.getMinuteOfHour(); second = now.getSecondOfMinute(); StringBuilder sb = new StringBuilder(); sb.append(LINKAGE_SUBJECT_PREFIX); sb.append(StressTester.randomString(8)); sb.append("_"); sb.append(Integer.toString(year)); if (month < 10) sb.append("0"); sb.append(Integer.toString(month)); if (day < 10) sb.append("0"); sb.append(Integer.toString(day)); sb.append("_"); if (hour < 10) sb.append("0"); sb.append(Integer.toString(hour)); if (minute < 10) sb.append("0"); sb.append(Integer.toString(minute)); if (second < 10) sb.append("0"); sb.append(Integer.toString(second)); return sb.toString(); }
From source file:TimeDate.Time.java
public Time() { DateTime tmr = new DateTime(); this.hora = tmr.getHourOfDay(); this.minutos = tmr.getMinuteOfHour(); this.segundos = tmr.getSecondOfMinute(); }
From source file:uk.ac.ucl.excites.sapelli.collector.activities.ExportActivity.java
License:Apache License
@SuppressLint("InflateParams") private void setDateRange(final int dtRangeIdx) { // Init current date time to show in dialog: DateTime current = dateRange[dtRangeIdx]; if (current == null) switch (dtRangeIdx) { case DT_RANGE_IDX_FROM: // default "from" time is today at 00:00:00: DateTime now = DateTime.now(); current = new DateTime(now.getYear(), now.getMonthOfYear(), now.getDayOfMonth(), 0, 0); break; case DT_RANGE_IDX_TO: // default "to" time is *now*: current = DateTime.now();//w w w. jav a 2 s. c o m break; } // UI elements: View view = getLayoutInflater().inflate(R.layout.dialog_datetime, null); final DatePicker datePicker = (DatePicker) view.findViewById(R.id.DTdatePicker); datePicker.updateDate(current.getYear(), current.getMonthOfYear(), current.getDayOfMonth()); final TimePicker timePicker = (TimePicker) view.findViewById(R.id.DTtimePicker); timePicker.setIs24HourView(true); timePicker.setCurrentHour(current.getHourOfDay()); timePicker.setCurrentMinute(current.getMinuteOfHour()); // Create the dialog AlertDialog.Builder builder = new Builder(this); // Set the title: builder.setTitle(getString( dtRangeIdx == DT_RANGE_IDX_FROM ? R.string.exportDateRangeFrom : R.string.exportDateRangeTo, '\u2026')) // Set UI: .setView(view) // Set the buttons: // OK: .setPositiveButton(android.R.string.ok, new Dialog.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { updateDateRange(dtRangeIdx, new DateTime(datePicker.getYear(), datePicker.getMonth(), datePicker.getDayOfMonth(), timePicker.getCurrentHour(), timePicker.getCurrentMinute(), 0, 0)); } }) // Cancel: .setNegativeButton(android.R.string.cancel, new Dialog.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { dialog.dismiss(); } }) // Any time: .setNeutralButton(StringUtils.capitalizeFirstLetter(getString(R.string.exportDateRangeAnytime)), new Dialog.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { updateDateRange(dtRangeIdx, null); // null = *any time* (no limit set) } }) // Create the dialog and show it. .create().show(); }