Example usage for org.joda.time LocalDateTime withMinuteOfHour

List of usage examples for org.joda.time LocalDateTime withMinuteOfHour

Introduction

In this page you can find the example usage for org.joda.time LocalDateTime withMinuteOfHour.

Prototype

public LocalDateTime withMinuteOfHour(int minute) 

Source Link

Document

Returns a copy of this datetime with the minute of hour field updated.

Usage

From source file:com.axelor.csv.script.ImportDateTime.java

License:Open Source License

public LocalDateTime updateMinute(LocalDateTime dateTime, String minute) {
    if (!Strings.isNullOrEmpty(minute)) {
        Matcher matcher = patternMonth.matcher(minute);
        if (matcher.find()) {
            Integer minutes = Integer.parseInt(matcher.group());
            if (minute.startsWith("+"))
                dateTime = dateTime.plusMinutes(minutes);
            else if (minute.startsWith("-"))
                dateTime = dateTime.minusMinutes(minutes);
            else/* ww w  .j a va2 s  .  c o m*/
                dateTime = dateTime.withMinuteOfHour(minutes);
        }
    }
    return dateTime;
}

From source file:control.Xray.java

public ArrayList<LocalDateTime> getDatesInPeriod(LocalDateTime startTime, LocalDateTime endTime) {
    ArrayList<LocalDateTime> dates = new ArrayList<>();
    LocalDateTime currentDate = new LocalDateTime(startTime);
    currentDate = currentDate.withHourOfDay(0);
    currentDate = currentDate.withMinuteOfHour(0);

    while (currentDate.isBefore(endTime)) {
        dates.add(currentDate);/* w  ww. j  a v a2  s .  com*/
        currentDate = currentDate.plusDays(1);
    }

    return dates;
}

From source file:view.popups.shift.ShiftPopup.java

private void initComboboxes() {

    cDate = new ComboBox();
    cDate.setPrefWidth(170);/*  ww  w .  j a v a  2s.  c  o  m*/

    LocalDateTime now = new LocalDateTime();
    now = now.withHourOfDay(0);
    now = now.withMinuteOfHour(0);
    LocalDateTime currentWeek = now;

    LocalDateTime threeMonthsForward = now.plusMonths(3);
    ArrayList<LocalDateTime> startDates = Xray.getInstance().getDatesInPeriod(currentWeek, threeMonthsForward);
    for (int i = 0; i < startDates.size(); i++) {
        if (startDates.get(i).getDayOfWeek() == 1) {
            cDate.getItems().add(startDates.get(i));
        }
    }

    Callback<ListView<LocalDateTime>, ListCell<LocalDateTime>> cellFactory = new Callback<ListView<LocalDateTime>, ListCell<LocalDateTime>>() {
        @Override
        public ListCell<LocalDateTime> call(ListView<LocalDateTime> param) {

            return new ListCell<LocalDateTime>() {
                @Override
                public void updateItem(LocalDateTime item, boolean empty) {
                    super.updateItem(item, empty);
                    if (!empty) {
                        String value = ScheduleHeader.WEEK_DAY_NAMES[item.getDayOfWeek() - 1];
                        value = value.replaceFirst(value.substring(1, value.length()),
                                value.substring(1, value.length()).toLowerCase());
                        setText("Uge " + item.getWeekOfWeekyear() + " den " + item.getDayOfMonth() + "/"
                                + item.getMonthOfYear() + " - " + value);
                    }
                }

            };
        }
    };

    cDate.setButtonCell(cellFactory.call(null));
    cDate.setCellFactory(cellFactory);

    cEmployee = new ComboBox();
    cEmployee.setPrefWidth(170);
    cEmployee.setDisable(true);

}