List of usage examples for org.joda.time DateTime getMinuteOfHour
public int getMinuteOfHour()
From source file:com.mpower.daktar.android.widgets.DateTimeWidget.java
License:Apache License
/** * Resets date to today./*from w ww . j a v a2s . c o m*/ */ @Override public void clearAnswer() { final DateTime ldt = new DateTime(); mDatePicker.init(ldt.getYear(), ldt.getMonthOfYear() - 1, ldt.getDayOfMonth(), mDateListener); mTimePicker.setCurrentHour(ldt.getHourOfDay()); mTimePicker.setCurrentMinute(ldt.getMinuteOfHour()); }
From source file:com.mpower.daktar.android.widgets.TimeWidget.java
License:Apache License
public TimeWidget(final Context context, final FormEntryPrompt prompt) { super(context, prompt); mTimePicker = new TimePicker(getContext()); mTimePicker.setFocusable(!prompt.isReadOnly()); mTimePicker.setEnabled(!prompt.isReadOnly()); final 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 . jav a 2s . com*/ // If there's an answer, use it. if (prompt.getAnswerValue() != null) { // create a new date time from date object using default time zone final DateTime ldt = new DateTime(((Date) ((TimeData) prompt.getAnswerValue()).getValue()).getTime()); System.out.println("retrieving:" + ldt); 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:com.mpower.daktar.android.widgets.TimeWidget.java
License:Apache License
/** * Resets time to today.// www .ja v a2 s .c om */ @Override public void clearAnswer() { final DateTime ldt = new DateTime(); mTimePicker.setCurrentHour(ldt.getHourOfDay()); mTimePicker.setCurrentMinute(ldt.getMinuteOfHour()); }
From source file:com.mpower.mintel.android.widgets.TimeWidget.java
License:Apache 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); }/*w ww . ja va 2 s . 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()); System.out.println("retrieving:" + ldt); 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:com.mvcoding.financius.feature.TimeDialogFragment.java
License:Open Source License
public static Observable<TimeDialogResult> show(@NonNull FragmentManager fragmentManager, int requestCode, @NonNull RxBus rxBus, long timestamp) { final DateTime date = new DateTime(timestamp); return show(fragmentManager, requestCode, rxBus, date.getHourOfDay(), date.getMinuteOfHour()); }
From source file:com.mvcoding.financius.feature.transaction.TransactionActivity.java
License:Open Source License
@NonNull @Override/*from ww w . j ava 2 s . c o m*/ public Observable<Long> onDateChanged() { final Observable<Long> dateObservable = rxBus.observe(DateDialogFragment.DateDialogResult.class) .mergeWith(RxView.clicks(dateButton).flatMap(o -> DateDialogFragment .show(getSupportFragmentManager(), REQUEST_DATE, rxBus, transaction.getDate()))) .map(dateDialogResult -> { final DateTime dateTime = new DateTime(transaction.getDate()); return new DateTime(dateDialogResult.getYear(), dateDialogResult.getMonthOfYear(), dateDialogResult.getDayOfMonth(), dateTime.getHourOfDay(), dateTime.getMinuteOfHour()) .getMillis(); }); final Observable<Long> timeObservable = rxBus.observe(TimeDialogFragment.TimeDialogResult.class) .mergeWith(RxView.clicks(timeButton).flatMap(o -> TimeDialogFragment .show(getSupportFragmentManager(), REQUEST_TIME, rxBus, transaction.getDate()))) .map(timeDialogResult -> { final DateTime dateTime = new DateTime(transaction.getDate()); return new DateTime(dateTime.getYear(), dateTime.getMonthOfYear(), dateTime.getDayOfMonth(), timeDialogResult.getHourOfDay(), timeDialogResult.getMinuteOfHour()).getMillis(); }); return Observable.merge(dateObservable, timeObservable); }
From source file:com.mycollab.vaadin.UserUIContext.java
License:Open Source License
/** * @param date is the UTC date value/*from w w w. j av a 2s . c om*/ * @return */ public static String formatDateTime(Date date) { if (date == null) { return ""; } else { DateTime jodaDate = new DateTime(date) .toDateTime(DateTimeZone.forTimeZone(UserUIContext.getUserTimeZone())); if (jodaDate.getHourOfDay() > 0 || jodaDate.getMinuteOfHour() > 0) { DateTimeFormatter formatter = DateTimeFormat.forPattern(MyCollabUI.getDateTimeFormat()) .withLocale(UserUIContext.getUserLocale()); return formatter.print(jodaDate); } else { DateTimeFormatter formatter = DateTimeFormat.forPattern(MyCollabUI.getDateFormat()) .withLocale(UserUIContext.getUserLocale()); return formatter.print(jodaDate); } } }
From source file:com.mycollab.vaadin.web.ui.field.DateTimeOptionField.java
License:Open Source License
@Override public void setPropertyDataSource(Property newDataSource) { Date value = (Date) newDataSource.getValue(); if (value != null) { DateTime jodaTime = new DateTime(value); jodaTime = jodaTime.toDateTime(DateTimeZone.forTimeZone(UserUIContext.getUserTimeZone())); int hrs = jodaTime.getHourOfDay(); int min = jodaTime.getMinuteOfHour(); String timeFormat = "AM"; if (hrs > 12) { hrs -= 12;// w w w .j a v a2 s . c om timeFormat = "PM"; } if ((hrs > 0 || min > 0) && hideTimeOption) { toggleHideTimeOption(false); } popupDateField.setPropertyDataSource(new ObjectProperty(jodaTime.toDate())); if (!hideTimeOption) { hourPickerComboBox.setPropertyDataSource(new ObjectProperty((hrs < 10) ? "0" + hrs : "" + hrs)); minutePickerComboBox.setPropertyDataSource(new ObjectProperty((min < 10) ? "0" + min : "" + min)); timeFormatComboBox.setPropertyDataSource(new ObjectProperty(timeFormat)); } } super.setPropertyDataSource(newDataSource); }
From source file:com.mycompany.login.mb.DateBean.java
public static void main(String[] args) { Date date = new Date(); DateTime dateTime = new DateTime(date); DateTime dateTeste = new DateTime(dateTime.getYear(), dateTime.getMonthOfYear(), dateTime.getDayOfMonth(), dateTime.getHourOfDay(), dateTime.getMinuteOfHour()); // System.out.println("ANO: " + dateTime.getYear()); // System.out.println("MES: " + dateTime.getMonthOfYear()); // System.out.println("DIA: " + dateTime.getDayOfMonth()); // System.out.println("HORA: " + dateTime.getHourOfDay()); // System.out.println("MINUTO: " + dateTime.getMinuteOfHour()); // System.out.println("Data Formatada:" + dateTime.getYear() + "/" + dateTime.getMonthOfYear() + "/" + dateTime.getDayOfMonth()); //System.out.println(dateTeste.toString("YYYY-MM-dd HH:mm")); LocalDate local = new LocalDate(date); System.out.println("Local Date: " + local); }
From source file:com.njlabs.amrita.aid.gpms.client.Gpms.java
License:Open Source License
private DateTime roundOffDate(DateTime target) { int minutes = target.getMinuteOfHour(); if (minutes > 0 && minutes < 15) { return target.withMinuteOfHour(15); } else if (minutes > 15 && minutes < 30) { return target.withMinuteOfHour(30); } else if (minutes > 30 && minutes < 45) { return target.withMinuteOfHour(45); } else if (minutes > 45 && minutes <= 59) { if (target.getHourOfDay() == 23) { return target.plusDays(1).withHourOfDay(0).withMinuteOfHour(0); } else {// w w w .j a v a2 s. c o m return target.plusHours(1).withMinuteOfHour(0); } } else { return target; } }