Example usage for org.joda.time DateTime getMinuteOfHour

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

Introduction

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

Prototype

public int getMinuteOfHour() 

Source Link

Document

Get the minute of hour field value.

Usage

From source file:uk.ac.ucl.excites.sapelli.collector.fragments.ExportFragment.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();/*from w  w w.  jav a  2s . co m*/
            break;
        }

    // UI elements:
    View view = getOwner().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 AlertDialog.Builder(getOwner());
    // 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();
}

From source file:uk.co.jassoft.markets.utils.article.ContentGrabber.java

private Date getDateValue(final String contentsToCheck) {
    if (contentsToCheck.isEmpty())
        return null;

    Parser parser = new Parser();
    List<DateGroup> groups = parser.parse(contentsToCheck);

    Date possibleDate = null;//from   w  w  w. j  a v a  2 s  .com

    for (DateGroup group : groups) {
        List<Date> dates = group.getDates();

        for (Date publishedDate : dates) {
            if (new DateTime(DateTimeZone.UTC).plusDays(1).isBefore(publishedDate.getTime())) {
                LOG.debug("Date is over 1 day in the future [{}]", publishedDate.toString());
                continue;
            }

            if (possibleDate == null) {
                possibleDate = publishedDate;

                if (group.isTimeInferred()) {
                    possibleDate = new DateTime(publishedDate).withTime(0, 0, 0, 0).toDate();
                }
                continue;
            }

            DateTime latestPublishedDate = new DateTime(publishedDate);

            if (!group.isTimeInferred()) {
                possibleDate = new DateTime(possibleDate).withTime(latestPublishedDate.getHourOfDay(),
                        latestPublishedDate.getMinuteOfHour(), latestPublishedDate.getSecondOfMinute(),
                        latestPublishedDate.getMillisOfSecond()).toDate();
            }

            if (!group.isDateInferred()) {
                possibleDate = new DateTime(possibleDate).withDate(latestPublishedDate.getYear(),
                        latestPublishedDate.getMonthOfYear(), latestPublishedDate.getDayOfMonth()).toDate();
            }
        }
    }

    if (possibleDate != null) {
        return possibleDate;
    }

    return null;
}

From source file:view.Configuration.java

/**
 * Read the preferences from disk and fill the text fields with the
 * appropriate data.//from   www .  ja  v  a  2  s  . co  m
 */
private void loadPreferences() {
    connectToJira.setSelected(preferences.connectToJiraAtStartup());
    urlTextField.setText(preferences.getJiraUrl());
    passwordPasswordField.setText(preferences.getPassword());
    usernaneTextField.setText(preferences.getUserName());

    DateTime alarmTime = preferences.getBeerTime();
    alarmDay.setSelectedIndex(alarmTime.getDayOfWeek() - 1);
    alarmHour.setSelectedItem(String.valueOf(alarmTime.getHourOfDay()));
    alarmMinute.setSelectedItem(String.valueOf(alarmTime.getMinuteOfHour()));
    killOnAlarm.setSelected(preferences.getKillOnBeer());
}