Example usage for org.joda.time LocalDateTime LocalDateTime

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

Introduction

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

Prototype

public LocalDateTime(Object instant) 

Source Link

Document

Constructs an instance from an Object that represents a datetime.

Usage

From source file:view.EmprestimoInternalFrame.java

private void RenovaEmprestimoBtnActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_RenovaEmprestimoBtnActionPerformed
    int idx[] = emprestimoTable.getSelectedRows();
    if (idx.length > 0) {
        int id_emprestimo = Integer
                .valueOf(emprestimoTable.getValueAt(emprestimoTable.getSelectedRow(), 0).toString());
        if (id_emprestimo != 0) {
            Emprestimo e = EmprestimoController.Pegar(id_emprestimo);
            LocalDateTime hoje = new LocalDateTime(System.currentTimeMillis());
            LocalDateTime fim = new LocalDateTime(e.getData_fim());
            int dias = Days.daysBetween(hoje, fim).getDays();
            dias = dias * -1;/* w w w .  j  ava 2s . c  om*/
            double total = 0.0;
            int response;
            if (dias > 0) {
                for (int i = 0; i < dias; i++) {
                    total = e.getId_exemplar().stream().map((_item) -> juros_dia).reduce(total,
                            (accumulator, _item) -> accumulator + _item);
                }
            }
            JLabel nome = new JLabel();
            nome.setFont(new Font("Dialog", Font.BOLD, 14));
            JLabel juros = new JLabel();
            juros.setFont(new Font("Dialog", Font.BOLD, 14));
            JLabel total_ex = new JLabel();
            total_ex.setFont(new Font("Dialog", Font.BOLD, 14));
            JSpinner diaSpinner = new JSpinner(new SpinnerNumberModel());
            diaSpinner.setFont(new Font("Dialog", Font.BOLD, 18));
            diaSpinner.setValue(prazo_default);
            Object[] message = { "Locatrio:", nome, "Total de Exemplares: ", total_ex, "Total de Juros:",
                    juros, "Dias p/ Devoluo:", diaSpinner, "O juros ser zerado. Renovar?" };
            nome.setText(emprestimoTable.getValueAt(emprestimoTable.getSelectedRow(), 1).toString());
            juros.setText("" + NumberFormat.getCurrencyInstance().format(total));
            total_ex.setText("" + e.getId_exemplar().size());

            response = JOptionPane.showConfirmDialog(null, message, "Devoluo", JOptionPane.YES_NO_OPTION,
                    JOptionPane.QUESTION_MESSAGE);
            if (response == JOptionPane.YES_OPTION) {
                int plus_days = Integer.valueOf(diaSpinner.getValue().toString());
                if (plus_days < 0)
                    plus_days = plus_days * -1;
                System.out.println("" + plus_days);
                if (EmprestimoController.Renovar(id_emprestimo, plus_days)) {
                    updateEmprestimoTable("");
                }
            }
        }
    } else
        RenovaEmprestimoBtn.setEnabled(false);
}

From source file:view.schema.AssignedAllRoomsRow.java

public AssignedAllRoomsRow(String shiftName, LocalDateTime startTime, ArrayList<TimeInvestment> shifts,
        int startHour, int startMinute, int periodLengthHour, int periodLengthMinute) {

    this.shifts = shifts;
    this.startTime = startTime;
    shiftTypeLabel = new RoomTile(shiftName);

    this.setOrientation(Orientation.HORIZONTAL);

    this.getChildren().add(shiftTypeLabel);

    //Tilfj vagter til dagene p ugen. i0 = mandag, i4 = fredag.
    for (int i = 0; i < 5; i++) {
        LocalDateTime date = startTime.plusDays(i);
        date = date.withField(DateTimeFieldType.hourOfDay(), startHour);
        date = date.withField(DateTimeFieldType.minuteOfHour(), startMinute);
        //Nulstil sekunder og millisekunder (vigtigt).
        date = date.withSecondOfMinute(0);
        date = date.withMillisOfSecond(0);

        LocalDateTime endDate = new LocalDateTime(date);
        endDate = endDate.plusHours(periodLengthHour).plusMinutes(periodLengthMinute);

        ShiftTile shiftTile = new ShiftTile(
                Xray.getInstance().getTimeInvestmentControl().getShiftsInPeriod(shifts, date, endDate));
        this.getChildren().add(shiftTile);

    }//from  ww  w . j a v  a 2s .  c  o  m
}

From source file:view.schema.AssignedRoomRow.java

public AssignedRoomRow(Room room, ArrayList<TimeInvestment> shifts, LocalDateTime startTime, int startHour,
        int startMinute, int periodLengthHour, int periodLengthMinute) {
    this.startTime = startTime;
    this.room = room;
    this.shifts = shifts;

    roomLabel = new RoomTile(room.getRoomName());

    //Tilfj rumnavn til venstre.
    this.getChildren().add(roomLabel);

    //Tilfj vagter til dagene p ugen. i0 = mandag, i4 = fredag.
    for (int i = 0; i < 5; i++) {
        LocalDateTime date = startTime.plusDays(i);
        date = date.withField(DateTimeFieldType.hourOfDay(), startHour);
        date = date.withField(DateTimeFieldType.minuteOfHour(), startMinute);
        //Nulstil sekunder og millisekunder (vigtigt).
        date = date.withSecondOfMinute(0);
        date = date.withMillisOfSecond(0);

        LocalDateTime endDate = new LocalDateTime(date);
        endDate = endDate.plusHours(periodLengthHour).plusMinutes(periodLengthMinute);

        ShiftTile shiftTile = new ShiftTile(
                Xray.getInstance().getTimeInvestmentControl().getShiftsInPeriod(shifts, date, endDate));

        this.getChildren().add(shiftTile);
    }/*from w w w  .j  av  a  2s. co  m*/

}