List of usage examples for org.joda.time DateTime getHourOfDay
public int getHourOfDay()
From source file:io.coala.xml.XmlUtil.java
License:Apache License
/** * @param date/*from w w w .j a v a 2s . c om*/ * @return a JAXP {@link XMLGregorianCalendar} */ public static XMLGregorianCalendar toDateTime(final DateTime date) { final XMLGregorianCalendar result = getDatatypeFactory().newXMLGregorianCalendar(); result.setYear(date.getYear()); result.setMonth(date.getMonthOfYear()); result.setDay(date.getDayOfMonth()); result.setTime(date.getHourOfDay(), date.getMinuteOfHour(), date.getSecondOfMinute(), date.getMillisOfSecond()); result.setTimezone(date.getZone().toTimeZone().getRawOffset() / 1000 / 60); // result.setTimezone(DatatypeConstants.FIELD_UNDEFINED); return result; }
From source file:io.github.blindio.prospero.core.utils.JodaDateTimeWrapper.java
License:Apache License
public JodaDateTimeWrapper withTimeString(String timeString) { DateTime newTime = DateTime.parse(timeString, formatTime); return this.withTime(newTime.getHourOfDay(), newTime.getMinuteOfHour()); }
From source file:io.spikex.core.util.CronEntry.java
License:Apache License
public boolean isDefined(final DateTime tm) { boolean defined = false; int month = tm.getMonthOfYear(); int day = tm.getDayOfMonth(); int dow = tm.getDayOfWeek(); int hour = tm.getHourOfDay(); int minute = tm.getMinuteOfHour(); boolean dayDowMatch = true; if (!isEveryDay()) { dayDowMatch = isDayDefined(day); }//w ww. java 2s . com if (!isEveryDow()) { dayDowMatch = isDowDefined(dow); } if (!isEveryDay() && !isEveryDow()) { dayDowMatch = (isDayDefined(day) || isDowDefined(dow)); } if (isMonthDefined(month) && dayDowMatch && isHourDefined(hour) && isMinuteDefined(minute)) { defined = true; } // System.out.println("Defined " + defined + " - month: " + month + " day: " + day + " dow: " + dow // +" hour: " + hour + " minute: " + minute + " dayOrDowMatch: " + dayDowMatch); // System.out.println("dayDowMatch: " + dayDowMatch + " isMonthDefined: " + isMonthDefined(month) // + " isHourDefined: " + isHourDefined(hour) + " isMinuteDefined: " + isMinuteDefined(minute)); return defined; }
From source file:io.warp10.script.functions.TSELEMENTS.java
License:Apache License
@Override public Object apply(WarpScriptStack stack) throws WarpScriptException { Object obj = stack.peek();//from w w w. j av a 2 s .co m String tz = null; if (obj instanceof String) { tz = (String) obj; stack.pop(); } else if (!(obj instanceof Long)) { throw new WarpScriptException(getName() + " operates on a timestamp or a timestamp + timezone."); } DateTimeZone dtz = this.tzones.get(tz); if (null == dtz) { dtz = DateTimeZone.forID(null == tz ? "UTC" : tz); this.tzones.put(tz, dtz); } obj = stack.pop(); if (!(obj instanceof Long)) { throw new WarpScriptException(getName() + " operates on a timestamp or a timestamp + timezone."); } long ts = (long) obj; // Convert ts to milliseconds long tsms = ts / Constants.TIME_UNITS_PER_MS; DateTime dt = new DateTime(tsms, dtz); // Extract components into an array List<Long> elements = new ArrayList<Long>(); elements.add((long) dt.getYear()); elements.add((long) dt.getMonthOfYear()); elements.add((long) dt.getDayOfMonth()); elements.add((long) dt.getHourOfDay()); elements.add((long) dt.getMinuteOfHour()); elements.add((long) dt.getSecondOfMinute()); elements.add(ts % Constants.TIME_UNITS_PER_S); elements.add((long) dt.getDayOfYear()); elements.add((long) dt.getDayOfWeek()); elements.add((long) dt.getWeekOfWeekyear()); stack.push(elements); return stack; }
From source file:io.warp10.script.mapper.MapperHourOfDay.java
License:Apache License
@Override public Object apply(Object[] args) throws WarpScriptException { long tick = (long) args[0]; long[] locations = (long[]) args[4]; long[] elevations = (long[]) args[5]; long location = locations[0]; long elevation = elevations[0]; DateTime dt = new DateTime(tick / Constants.TIME_UNITS_PER_MS, this.dtz); return new Object[] { tick, location, elevation, dt.getHourOfDay() }; }
From source file:it.fabaris.wfp.widget.DateTimeWidget.java
License:Open Source License
/** * set the answer to the answer Widget/*from w ww.jav a 2s .co m*/ * getting in it from the FormEntryPrompt * otherwise create time widget with * the current time */ private void setAnswer() { if (mPrompt.getAnswerValue() != null) { DateTime ldt = new DateTime(((Date) ((DateTimeData) mPrompt.getAnswerValue()).getValue()).getTime()); //mDatePicker.init(ldt.getYear(), ldt.getMonthOfYear() - 1, ldt.getDayOfMonth(), mDateListener); //LA DATA DI SINCRONIZZAZIONE ERA SETTATA CON UN MESE INDIETRO mDatePicker.init(ldt.getYear(), ldt.getMonthOfYear(), ldt.getDayOfMonth(), mDateListener); mTimePicker.setCurrentHour(ldt.getHourOfDay()); mTimePicker.setCurrentMinute(ldt.getMinuteOfHour()); } else { // create time widget with current time as of right now clearAnswer(); } }
From source file:it.fabaris.wfp.widget.TimeWidget.java
License:Open Source License
public TimeWidget(Context context, final FormEntryPrompt prompt) { super(context, prompt); mTimePicker = new TimePicker(getContext()); mTimePicker.setFocusable(!prompt.isReadOnly()); mTimePicker.setEnabled(!prompt.isReadOnly()); String clockType = android.provider.Settings.System.getString(context.getContentResolver(), android.provider.Settings.System.TIME_12_24); if (clockType == null || clockType.equalsIgnoreCase("24")) { mTimePicker.setIs24HourView(true); }//from w w w.j a v a2s .c o m // If there's an answer, use it. if (prompt.getAnswerValue() != null) { // create a new date time from date object using default time zone DateTime ldt = new DateTime(((Date) ((TimeData) prompt.getAnswerValue()).getValue()).getTime()); mTimePicker.setCurrentHour(ldt.getHourOfDay()); mTimePicker.setCurrentMinute(ldt.getMinuteOfHour()); } else { // create time widget with current time as of right now clearAnswer(); } setGravity(Gravity.LEFT); addView(mTimePicker); }
From source file:jtodo.ui.TaskEditorWindow.java
License:Open Source License
private void fillInValues() { logger.log(Level.INFO, "Automatically filling in the values for the task"); fieldName.setText(task.getName());//w ww.j a v a2 s . c o m fieldDescription.setText(task.getDescription()); comboBoxPriority.setSelectedItem(task.getPriority()); if (task.isDeadlineActive()) { DateTime dateTime = task.getDeadline().getDateTime(); comboBoxDay.setSelectedIndex(dateTime.getDayOfMonth() - 1); comboBoxMonth.setSelectedIndex(dateTime.getMonthOfYear() - 1); fieldYear.setText("" + dateTime.getYear()); comboBoxTime.setSelectedItem(dateTime.getHourOfDay() + ":" + dateTime.getMinuteOfHour()); checkBoxDeadlineActive.setSelected(true); } else { checkBoxDeadlineActive.setSelected(false); setDateSelectionEnabledIfCheckBoxActive(); } }
From source file:julian.lylly.model.Util.java
public static String dateTimeToString(DateTime dt) { String y = dt.getYear() + ""; String m = longTo2DigitString(dt.getMonthOfYear()); String d = longTo2DigitString(dt.getDayOfMonth()); String h = longTo2DigitString(dt.getHourOfDay()); String mi = longTo2DigitString(dt.getMinuteOfHour()); return y + "-" + m + "-" + d + " " + h + ":" + mi; }
From source file:kr.debop4j.timeperiod.TimeCalendar.java
License:Apache License
@Override public int getHourOfDay(DateTime time) { return time.getHourOfDay(); }