Example usage for org.joda.time DateTime getHourOfDay

List of usage examples for org.joda.time DateTime getHourOfDay

Introduction

In this page you can find the example usage for org.joda.time DateTime getHourOfDay.

Prototype

public int getHourOfDay() 

Source Link

Document

Get the hour of day field value.

Usage

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;//ww 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 {/*from   w  w  w. jav  a  2 s  .  c o  m*/
            return target.plusHours(1).withMinuteOfHour(0);
        }
    } else {
        return target;
    }
}

From source file:com.njlabs.amrita.aid.gpms.ui.PassApplyActivity.java

License:Open Source License

private void loadDateTimePicker(final DateTime startDate, final View v, final String toModify) {
    MonthAdapter.CalendarDay calendarDay = new MonthAdapter.CalendarDay();
    calendarDay.setDay(startDate.getYear(), startDate.getMonthOfYear() - 1, startDate.getDayOfMonth());

    CalendarDatePickerDialogFragment cdp = new CalendarDatePickerDialogFragment()
            .setOnDateSetListener(new CalendarDatePickerDialogFragment.OnDateSetListener() {
                @Override/*  w  w  w .  j a va 2s  .  c  o m*/
                public void onDateSet(CalendarDatePickerDialogFragment dialog, final int year,
                        final int monthOfYear, final int dayOfMonth) {

                    RadialTimePickerDialogFragment rtpd = new RadialTimePickerDialogFragment()
                            .setOnTimeSetListener(new RadialTimePickerDialogFragment.OnTimeSetListener() {
                                @Override
                                public void onTimeSet(RadialTimePickerDialogFragment dialog, int hourOfDay,
                                        int minute) {
                                    Ln.d(minute);
                                    boolean error = false;
                                    DateTime selectedDateTime = new DateTime(year, monthOfYear + 1, dayOfMonth,
                                            hourOfDay, minute);
                                    if (toModify.equals("fromDate")) {
                                        fromDate = selectedDateTime;
                                        findViewById(R.id.to_date_btn).setEnabled(true);
                                    } else if (toModify.equals("toDate")) {
                                        toDate = selectedDateTime;
                                        if (toDate.getMillis() <= fromDate.getMillis()) {
                                            error = true;
                                            Snackbar.make(parentView,
                                                    "The end date should be after the from date.",
                                                    Snackbar.LENGTH_LONG).show();
                                        }
                                    }
                                    if (!error) {
                                        ((Button) v).setText(selectedDateTime.toString(Gpms.dateFormat));
                                    }

                                }
                            }).setStartTime(startDate.getHourOfDay(), (startDate.getMinuteOfHour() - 1 == -1 ? 0
                                    : startDate.getMinuteOfHour() - 1))
                            .setThemeDark(false);
                    rtpd.show(getSupportFragmentManager(), "FRAG_TAG_TIME_PICKER");

                }
            }).setFirstDayOfWeek(Calendar.SUNDAY)
            .setPreselectedDate(startDate.getYear(), startDate.getMonthOfYear() - 1, startDate.getDayOfMonth())
            .setDateRange(calendarDay, null).setThemeLight();
    cdp.show(getSupportFragmentManager(), "FRAG_TAG_DATE_PICKER");

}

From source file:com.pandits.opensource.JodaTimeUtil.java

License:Open Source License

public int getHourOfTheDay(long timeInMillis, TimeZone timeZone) {
    DateTime dateTime = createDateTime(timeInMillis, timeZone);
    return dateTime.getHourOfDay();
}

From source file:com.pureblue.quant.util.frequency.Hourly.java

@Override
public DateTime periodBegin(DateTime time) {
    return new DateTime(time.getYear(), time.getMonthOfYear(), time.getDayOfMonth(), time.getHourOfDay(), 0, 0,
            0, time.getZone());//from ww w . j a v  a  2 s.  co  m
}

From source file:com.pureblue.quant.util.frequency.Minute.java

@Override
public DateTime periodBegin(DateTime time) {
    return new DateTime(time.getYear(), time.getMonthOfYear(), time.getDayOfMonth(), time.getHourOfDay(),
            time.getMinuteOfHour(), 0, 0, time.getZone());
}

From source file:com.pureblue.quant.util.frequency.Second.java

@Override
public DateTime periodBegin(DateTime time) {
    return new DateTime(time.getYear(), time.getMonthOfYear(), time.getDayOfMonth(), time.getHourOfDay(),
            time.getMinuteOfHour(), time.getSecondOfMinute(), 0, time.getZone());
}

From source file:com.sap.dirigible.runtime.metrics.TimeUtils.java

License:Open Source License

private static DateTime dateTimeCeiling(DateTime dt, Period p) {
    if (p.getYears() != 0) {
        return dt.yearOfEra().roundCeilingCopy().minusYears(dt.getYearOfEra() % p.getYears());
    } else if (p.getMonths() != 0) {
        return dt.monthOfYear().roundCeilingCopy().minusMonths((dt.getMonthOfYear() - 1) % p.getMonths());
    } else if (p.getWeeks() != 0) {
        return dt.weekOfWeekyear().roundCeilingCopy().minusWeeks((dt.getWeekOfWeekyear() - 1) % p.getWeeks());
    } else if (p.getDays() != 0) {
        return dt.dayOfMonth().roundCeilingCopy().minusDays((dt.getDayOfMonth() - 1) % p.getDays());
    } else if (p.getHours() != 0) {
        return dt.hourOfDay().roundCeilingCopy().minusHours(dt.getHourOfDay() % p.getHours());
    } else if (p.getMinutes() != 0) {
        return dt.minuteOfHour().roundCeilingCopy().minusMinutes(dt.getMinuteOfHour() % p.getMinutes());
    } else if (p.getSeconds() != 0) {
        return dt.secondOfMinute().roundCeilingCopy().minusSeconds(dt.getSecondOfMinute() % p.getSeconds());
    }/*from w  ww . j a  v  a 2 s  . c  o  m*/
    return dt.millisOfSecond().roundCeilingCopy().minusMillis(dt.getMillisOfSecond() % p.getMillis());
}

From source file:com.serotonin.mango.vo.mailingList.MailingList.java

License:Open Source License

private static int getIntervalIdAt(DateTime dt) {
    int interval = 0;
    interval += dt.getMinuteOfHour() / 15;
    interval += dt.getHourOfDay() * 4;
    interval += (dt.getDayOfWeek() - 1) * 96;
    return interval;
}