Example usage for org.joda.time Days daysBetween

List of usage examples for org.joda.time Days daysBetween

Introduction

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

Prototype

public static Days daysBetween(ReadablePartial start, ReadablePartial end) 

Source Link

Document

Creates a Days representing the number of whole days between the two specified partial datetimes.

Usage

From source file:hotelmgmt.UserView.java

/**
 * The Employee Menu// w w  w  . j a  va2  s . c o m
 */
public void employeeMenu() {
    JFrame frame = new JFrame();
    frame.setTitle("Employee Menu");
    frame.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
    frame.setLayout(new BorderLayout());
    JPanel empPanel = new JPanel();
    list = new JList(listModel);
    list.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
    list.setPreferredSize(new Dimension(600, 550));
    //empPanel.add(list);
    empPanel.add(new JScrollPane(list));
    frame.add(empPanel, BorderLayout.CENTER);

    TextField name;
    name = new TextField("", 20);
    JLabel nameLabel = new JLabel("          Customer Name: ");
    nameLabel.setVisible(true);
    name.setVisible(true);
    TextField start, end;
    start = new TextField("", 15);
    end = new TextField("", 15);

    JButton leftButton = new JButton("Left");
    leftButton.setVisible(false);
    JButton blankButton = new JButton("Blank");
    blankButton.setVisible(false);
    JButton logoutButton = new JButton("Logout");
    JButton checkInButton = new JButton("Check In");
    JButton checkOutButton = new JButton("Check Out");
    JButton roomsButton = new JButton("Display Rooms");
    checkInButton.setVisible(false);
    checkOutButton.setVisible(false);
    JButton displayCustomersButton = new JButton("Display All Customers");
    JButton displayAllReservationsButton = new JButton("Display All Reservations");
    JButton reserveButton = new JButton("Display Reservations");
    reserveButton.setPreferredSize(new Dimension(150, 26));
    JButton addcustomerButton = new JButton("Add Customer");
    JButton editCustomerButton = new JButton("Edit Customer");
    JButton deleteCustomerButton = new JButton("Delete Customer");
    editCustomerButton.setVisible(false);
    deleteCustomerButton.setVisible(false);

    JPanel bottomPanel = new JPanel();
    bottomPanel.add(displayCustomersButton);
    bottomPanel.add(displayAllReservationsButton);
    bottomPanel.add(addcustomerButton);
    bottomPanel.add(logoutButton);
    frame.add(bottomPanel, BorderLayout.SOUTH);

    JPanel buttonPanel = new JPanel();
    buttonPanel.setLayout(new GridLayout(0, 6, 2, 10));
    buttonPanel.add(roomsButton);
    buttonPanel.add(reserveButton);
    buttonPanel.add(leftButton);
    buttonPanel.add(blankButton);
    buttonPanel.add(checkInButton);
    buttonPanel.add(checkOutButton);
    JLabel startLabel = new JLabel("          Start Date:");
    buttonPanel.add(startLabel);
    buttonPanel.add(start);
    JLabel endLabel = new JLabel("          End Date:");
    buttonPanel.add(endLabel);
    buttonPanel.add(end);
    buttonPanel.add(nameLabel);
    buttonPanel.add(name);
    buttonPanel.add(editCustomerButton);
    buttonPanel.add(deleteCustomerButton);
    frame.add(buttonPanel, BorderLayout.NORTH);

    addcustomerButton.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent event) {
            editCustomerButton.setVisible(false);
            deleteCustomerButton.setVisible(false);
            addEmployeeorCustomer(false, true);
        }
    });

    logoutButton.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent event) {
            logout();
            listModel.clear();
            frame.dispose();
        }
    });

    displayAllReservationsButton.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent event) {
            editCustomerButton.setVisible(false);
            deleteCustomerButton.setVisible(false);
            listModel.clear();
            hotel.displayReservations();
        }
    });

    displayCustomersButton.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent event) {
            editCustomerButton.setVisible(true);
            deleteCustomerButton.setVisible(true);
            listModel.clear();
            hotel.displayCusList();
        }
    });

    editCustomerButton.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent event) {
            //                editPerson(false, true);
            EditCustomer edCus = new EditCustomer(hotel);
            edCus.setVisible(true);
        }
    });

    deleteCustomerButton.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent event) {
            try {
                int idIndex = list.getSelectedValue().indexOf("ID:");
                int paymentIndex = list.getSelectedValue().indexOf("Payment");
                String cusId = list.getSelectedValue().substring(idIndex + 4, paymentIndex - 1);
                hotel.deleteCustomerManual(Integer.parseInt(cusId));
                listModel.clear();
            } catch (NullPointerException error) {
                speakError(error.toString());
            } catch (StringIndexOutOfBoundsException error) {
                speakError(error.toString());
            }
        }
    });

    roomsButton.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent event) {
            editCustomerButton.setVisible(false);
            deleteCustomerButton.setVisible(false);
            listModel.clear();
            checkOutButton.setVisible(false);
            String startd = checkDate(start.getText());
            String endd = checkDate(end.getText());
            if (startd != "" && endd != "") {
                LocalDate startdate = LocalDate.parse(startd, DateTimeFormat.forPattern("MM/dd/yyyy"));
                LocalDate enddate = LocalDate.parse(endd, DateTimeFormat.forPattern("MM/dd/yyyy"));
                int numdays = Days.daysBetween(startdate, enddate).getDays();
                if (numdays <= 0)
                    speakError("Check out date must be after check in date");
                else
                    hotel.displayRoomsAvailable(startdate, enddate);
                checkInButton.setVisible(true);
                leftButton.setText("Reserve Room");
                leftButton.setVisible(true);
                for (ActionListener al : leftButton.getActionListeners())
                    leftButton.removeActionListener(al);
                leftButton.addActionListener(new ActionListener() {
                    public void actionPerformed(ActionEvent event) {
                        try {
                            int priceindex = list.getSelectedValue().indexOf("Price:");
                            int ID = -1;
                            String username = name.getText();
                            if (hotel.findCustomer(username) > 0) {
                                ID = hotel.findCustomer(username);
                                hotel.bookRoom(true, ID, list.getSelectedValue().substring(11, priceindex - 2),
                                        startdate, enddate);
                                listModel.clear();
                                hotel.displayRoomsAvailable(startdate, enddate);
                            } else {
                                hotel.displayCusList();
                                idFrame(false, true, false, false, false, priceindex, startdate, enddate,
                                        "noType");
                            }
                        } catch (NullPointerException error) {
                            speakError("Error");
                        }
                    }
                });
                for (ActionListener al : checkInButton.getActionListeners())
                    checkInButton.removeActionListener(al);
                checkInButton.addActionListener(new ActionListener() {
                    public void actionPerformed(ActionEvent event) {
                        try {
                            int priceindex = list.getSelectedValue().indexOf("Price:");
                            int ID = -1;
                            String username = name.getText();
                            if (hotel.findCustomer(username) > 0) {
                                ID = hotel.findCustomer(username);
                                hotel.bookRoom(true, ID, list.getSelectedValue().substring(11, priceindex - 2),
                                        startdate, enddate);
                                hotel.bookRoom(false, ID, list.getSelectedValue().substring(11, priceindex - 2),
                                        startdate, enddate);
                                listModel.clear();
                                hotel.displayRoomsAvailable(startdate, enddate);
                            } else {
                                hotel.displayCusList();
                                idFrame(false, false, false, true, false, priceindex, startdate, enddate,
                                        "noType");
                            }
                        } catch (NullPointerException error) {
                            speakError("Error");
                        }
                    }
                });
            }
        }
    });

    reserveButton.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent event) {
            editCustomerButton.setVisible(false);
            deleteCustomerButton.setVisible(false);
            listModel.clear();
            nameLabel.setVisible(true);
            name.setVisible(true);
            checkInButton.setVisible(false);
            checkOutButton.setVisible(true);
            for (ActionListener al : checkInButton.getActionListeners())
                checkInButton.removeActionListener(al);
            String username = name.getText();
            if (username != " ") {
                if (hotel.findCustomer(username) > 0) {
                    int ID = hotel.findCustomer(username);
                    hotel.displayCustomerBalance(ID);
                } else {
                    hotel.displayCusList();
                    String empty = "03/01/2015";
                    LocalDate emptydate = LocalDate.parse(empty, DateTimeFormat.forPattern("MM/dd/yyyy"));
                    idFrame(true, false, false, false, false, 0, emptydate, emptydate, "noType");
                }
            } else
                speakError("Enter a customer name");
            leftButton.setText("Delete Reservation");
            leftButton.setVisible(true);
            for (ActionListener al : leftButton.getActionListeners())
                leftButton.removeActionListener(al);
            leftButton.addActionListener(new ActionListener() {
                public void actionPerformed(ActionEvent event) {
                    System.out.println(list.getSelectedIndex());
                    String username = name.getText();
                    if (hotel.findCustomer(username) > 0) {
                        int ID = hotel.findCustomer(username);
                        hotel.removeBookRoom(ID, list.getSelectedIndex());
                        listModel.clear();
                        //hotel.displayCustomerBalance(ID);
                    } else {
                        hotel.removeBookRoom(customerID, list.getSelectedIndex());
                        listModel.clear();
                    }
                }
            });
            checkOutButton.addActionListener(new ActionListener() {
                public void actionPerformed(ActionEvent event) {
                    System.out.println(list.getSelectedIndex());
                    String username = name.getText();
                    if (hotel.findCustomer(username) > 0) {
                        int ID = hotel.findCustomer(username);
                        hotel.removeBookRoom(ID, list.getSelectedIndex());
                        listModel.clear();
                        //hotel.displayCustomerBalance(ID);
                    } else {
                        hotel.removeBookRoom(customerID, list.getSelectedIndex());
                        listModel.clear();
                    }
                }
            });
            checkInButton.setVisible(true);
            for (ActionListener al : checkInButton.getActionListeners())
                checkInButton.removeActionListener(al);
            checkInButton.addActionListener(new ActionListener() {
                public void actionPerformed(ActionEvent event) {
                    try {
                        System.out.println(list.getSelectedIndex());
                        String username = name.getText();
                        int startIndex = list.getSelectedValue().indexOf("Start:");
                        int endIndex = list.getSelectedValue().indexOf("End:");
                        int typeIndex = list.getSelectedValue().indexOf("Type:");
                        int balanceIndex = list.getSelectedValue().indexOf("Balance:");
                        String startString = list.getSelectedValue().substring(startIndex + 7, endIndex - 1);
                        LocalDate startdate = LocalDate.parse(startString,
                                DateTimeFormat.forPattern("yyyy-MM-dd"));
                        String endString = list.getSelectedValue().substring(endIndex + 5, endIndex + 15);
                        LocalDate enddate = LocalDate.parse(endString, DateTimeFormat.forPattern("yyyy-MM-dd"));
                        String type = list.getSelectedValue().substring(typeIndex + 6, balanceIndex - 4);
                        if (hotel.findCustomer(username) > 0) {
                            int ID = hotel.findCustomer(username);
                            hotel.bookRoom(false, ID, type, startdate, enddate);
                            listModel.clear();
                            hotel.displayCustomerBalance(ID);
                        } else {
                            hotel.displayCusList();
                            idFrame(false, false, false, false, true, 0, startdate, enddate, type);
                        }
                    } catch (NullPointerException error) {
                        speakError("Error");
                    }
                }
            });
        }
    });

    frame.setPreferredSize(new Dimension(950, 600));
    frame.pack();
    frame.setVisible(true);
    frame.addWindowListener(new WindowAdapter() {
        @Override
        public void windowClosing(WindowEvent event) {
            logout();
            listModel.clear();
            frame.dispose();
        }
    });
}

From source file:hotelmgmt.UserView.java

/**
 * The Manager Menu/*  w  w w.  jav  a 2s . co m*/
 */
private void managerMenu() {
    //Create the window.
    JFrame mainframe = new JFrame("Manager Menu");

    //******employee options       
    JPanel frame = new JPanel();
    frame.setLayout(new BorderLayout());
    JPanel empPanel = new JPanel();
    list = new JList(listModel);
    list.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
    list.setPreferredSize(new Dimension(600, 550));
    //empPanel.add(list);
    empPanel.add(new JScrollPane(list));
    frame.add(empPanel, BorderLayout.CENTER);

    TextField customerName;
    customerName = new TextField("", 20);
    JLabel nameLabel = new JLabel("          Customer Name: ");
    nameLabel.setVisible(true);
    customerName.setVisible(true);
    TextField start, end;
    start = new TextField("", 15);
    end = new TextField("", 15);

    JButton leftButton = new JButton("Left");
    leftButton.setVisible(false);
    JButton blankButton = new JButton("Blank");
    blankButton.setVisible(false);
    JButton logoutButton = new JButton("Logout");
    logoutButton.setVisible(true);
    JButton checkInButton = new JButton("Check In");
    JButton checkOutButton = new JButton("Check Out");
    JButton roomsButton = new JButton("Display Rooms");
    checkInButton.setVisible(false);
    checkOutButton.setVisible(false);
    JButton displayCustomersButton = new JButton("Display All Customers");
    JButton displayAllReservationsButton = new JButton("Display All Reservations");
    JButton reserveButton = new JButton("Display Reservations");
    reserveButton.setPreferredSize(new Dimension(150, 26));
    JButton addCustomerButton = new JButton("Add Customer");
    JButton editCustomerButton = new JButton("Edit Customer");
    JButton deleteCustomerButton = new JButton("Delete Customer");
    editCustomerButton.setVisible(false);
    deleteCustomerButton.setVisible(false);

    JPanel bottomPanel = new JPanel();
    bottomPanel.add(displayCustomersButton);
    bottomPanel.add(displayAllReservationsButton);
    bottomPanel.add(addCustomerButton);
    bottomPanel.add(logoutButton);
    frame.add(bottomPanel, BorderLayout.SOUTH);

    JPanel buttonPanel = new JPanel();
    buttonPanel.setLayout(new GridLayout(0, 6, 2, 10));
    buttonPanel.add(roomsButton);
    buttonPanel.add(reserveButton);
    buttonPanel.add(leftButton);
    buttonPanel.add(blankButton);
    buttonPanel.add(checkInButton);
    buttonPanel.add(checkOutButton);
    JLabel startLabel = new JLabel("          Start Date:");
    buttonPanel.add(startLabel);
    buttonPanel.add(start);
    JLabel endLabel = new JLabel("          End Date:");
    buttonPanel.add(endLabel);
    buttonPanel.add(end);
    buttonPanel.add(nameLabel);
    buttonPanel.add(customerName);
    buttonPanel.add(editCustomerButton);
    buttonPanel.add(deleteCustomerButton);
    frame.add(buttonPanel, BorderLayout.NORTH);

    addCustomerButton.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent event) {
            editCustomerButton.setVisible(false);
            deleteCustomerButton.setVisible(false);
            addEmployeeorCustomer(false, true);
        }
    });

    logoutButton.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent event) {
            logout();
            listModel.clear();
            mainframe.dispose();
        }
    });

    displayAllReservationsButton.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent event) {
            listModel.clear();
            editCustomerButton.setVisible(false);
            deleteCustomerButton.setVisible(false);
            hotel.displayReservations();
        }
    });

    displayCustomersButton.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent event) {
            listModel.clear();
            hotel.displayCusList();
            deleteCustomerButton.setVisible(true);
            editCustomerButton.setVisible(true);
        }
    });

    deleteCustomerButton.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent event) {

            DeleteCustomer delCus = new DeleteCustomer(hotel);
            delCus.setVisible(true);
        }
    });

    editCustomerButton.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent event) {
            //                editPerson(false, true);  // moor?
            EditCustomer edCus = new EditCustomer(hotel);
            edCus.setVisible(true);
        }
    });

    roomsButton.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent event) {
            listModel.clear();
            checkOutButton.setVisible(false);
            editCustomerButton.setVisible(false);
            deleteCustomerButton.setVisible(false);
            String startd = checkDate(start.getText());
            String endd = checkDate(end.getText());
            if (startd != "" && endd != "") {
                LocalDate startdate = LocalDate.parse(startd, DateTimeFormat.forPattern("MM/dd/yyyy"));
                LocalDate enddate = LocalDate.parse(endd, DateTimeFormat.forPattern("MM/dd/yyyy"));
                int numdays = Days.daysBetween(startdate, enddate).getDays();
                if (numdays <= 0)
                    speakError("Check out date must be after check in date");
                else
                    hotel.displayRoomsAvailable(startdate, enddate);
                checkInButton.setVisible(true);
                leftButton.setText("Reserve Room");
                leftButton.setVisible(true);
                for (ActionListener al : leftButton.getActionListeners())
                    leftButton.removeActionListener(al);
                leftButton.addActionListener(new ActionListener() {
                    public void actionPerformed(ActionEvent event) {
                        try {
                            int priceindex = list.getSelectedValue().indexOf("Price:");
                            int ID = -1;
                            System.out.println(list.getSelectedIndex());
                            String username = customerName.getText();
                            if (hotel.findCustomer(username) > 0) {
                                ID = hotel.findCustomer(username);
                                hotel.bookRoom(true, ID, list.getSelectedValue().substring(11, priceindex - 2),
                                        startdate, enddate);
                                listModel.clear();
                                hotel.displayRoomsAvailable(startdate, enddate);
                            } else {
                                hotel.displayCusList();
                                idFrame(false, true, false, false, false, priceindex, startdate, enddate,
                                        "noType");
                            }
                        } catch (NullPointerException error) {
                            speakError("Error");
                        }
                    }
                });
                for (ActionListener al : checkInButton.getActionListeners())
                    checkInButton.removeActionListener(al);
                checkInButton.addActionListener(new ActionListener() {
                    public void actionPerformed(ActionEvent event) {
                        try {
                            int priceindex = list.getSelectedValue().indexOf("Price:");
                            int ID = -1;
                            String username = customerName.getText();
                            if (hotel.findCustomer(username) > 0) {
                                ID = hotel.findCustomer(username);
                                hotel.bookRoom(true, ID, list.getSelectedValue().substring(11, priceindex - 2),
                                        startdate, enddate);
                                hotel.bookRoom(false, ID, list.getSelectedValue().substring(11, priceindex - 2),
                                        startdate, enddate);
                                listModel.clear();
                                hotel.displayRoomsAvailable(startdate, enddate);
                            } else {
                                hotel.displayCusList();
                                idFrame(false, false, false, true, false, priceindex, startdate, enddate,
                                        "noType");
                            }
                        } catch (NullPointerException error) {
                            speakError("Error");
                        }
                    }
                });
            }
        }
    });

    reserveButton.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent event) {
            listModel.clear();
            nameLabel.setVisible(true);
            customerName.setVisible(true);
            checkInButton.setVisible(false);
            checkOutButton.setVisible(true);
            editCustomerButton.setVisible(false);
            deleteCustomerButton.setVisible(false);
            for (ActionListener al : checkInButton.getActionListeners())
                checkInButton.removeActionListener(al);
            String username = customerName.getText();
            if (username != " ") {
                if (hotel.findCustomer(username) > 0) {
                    int ID = hotel.findCustomer(username);
                    hotel.displayCustomerBalance(ID);
                } else {
                    hotel.displayCusList();
                    String empty = "03/01/2015";
                    LocalDate emptydate = LocalDate.parse(empty, DateTimeFormat.forPattern("MM/dd/yyyy"));
                    idFrame(true, false, false, false, false, 0, emptydate, emptydate, "noType");
                }
            } else
                speakError("Enter a customer name");
            leftButton.setText("Delete Reservation");
            leftButton.setVisible(true);
            for (ActionListener al : leftButton.getActionListeners())
                leftButton.removeActionListener(al);
            leftButton.addActionListener(new ActionListener() {
                public void actionPerformed(ActionEvent event) {
                    System.out.println(list.getSelectedIndex());
                    String username = customerName.getText();
                    if (hotel.findCustomer(username) > 0) {
                        int ID = hotel.findCustomer(username);
                        hotel.removeBookRoom(ID, list.getSelectedIndex());
                        listModel.clear();
                        //hotel.displayCustomerBalance(ID);
                    } else {
                        hotel.removeBookRoom(customerID, list.getSelectedIndex());
                        listModel.clear();
                    }
                }
            });
            checkOutButton.addActionListener(new ActionListener() {
                public void actionPerformed(ActionEvent event) {
                    System.out.println(list.getSelectedIndex());
                    String username = customerName.getText();
                    if (hotel.findCustomer(username) > 0) {
                        int ID = hotel.findCustomer(username);
                        hotel.removeBookRoom(ID, list.getSelectedIndex());
                        listModel.clear();
                        //hotel.displayCustomerBalance(ID);
                    } else {
                        hotel.removeBookRoom(customerID, list.getSelectedIndex());
                        listModel.clear();
                    }
                }
            });
            checkInButton.setVisible(true);
            for (ActionListener al : checkInButton.getActionListeners())
                checkInButton.removeActionListener(al);
            checkInButton.addActionListener(new ActionListener() {
                public void actionPerformed(ActionEvent event) {
                    try {
                        String username = customerName.getText();
                        int startIndex = list.getSelectedValue().indexOf("Start:");
                        int endIndex = list.getSelectedValue().indexOf("End:");
                        int typeIndex = list.getSelectedValue().indexOf("Type:");
                        int balanceIndex = list.getSelectedValue().indexOf("Balance:");
                        String startString = list.getSelectedValue().substring(startIndex + 7, endIndex - 1);
                        LocalDate startdate = LocalDate.parse(startString,
                                DateTimeFormat.forPattern("yyyy-MM-dd"));
                        String endString = list.getSelectedValue().substring(endIndex + 5, endIndex + 15);
                        LocalDate enddate = LocalDate.parse(endString, DateTimeFormat.forPattern("yyyy-MM-dd"));
                        String type = list.getSelectedValue().substring(typeIndex + 6, balanceIndex - 4);
                        if (hotel.findCustomer(username) > 0) {
                            int ID = hotel.findCustomer(username);
                            hotel.bookRoom(false, ID, type, startdate, enddate);
                            listModel.clear();
                            hotel.displayCustomerBalance(ID);
                        } else {
                            hotel.displayCusList();
                            idFrame(false, false, false, false, true, 0, startdate, enddate, type);
                        }
                    } catch (NullPointerException error) {
                        speakError("Error");
                    }
                }
            });
        }
    });

    frame.setPreferredSize(new Dimension(950, 600));
    frame.setVisible(true);

    //*****manager options       
    JPanel managerframe = new JPanel();
    managerframe.setLayout(new BorderLayout());
    JPanel managerCenterPanel = new JPanel();
    list2 = new JList(listModel);
    list2.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
    list2.setPreferredSize(new Dimension(600, 550));
    //managerCenterPanel.add(list2);
    managerCenterPanel.add(new JScrollPane(list2));
    managerframe.add(managerCenterPanel, BorderLayout.CENTER);

    JButton managerLogoutButton = new JButton("Logout");
    JButton listRoomsButton = new JButton("Display Rooms");
    JButton displayEmployeesButton = new JButton("Display All Employees");
    JButton displayTotalButton = new JButton("Display Total");
    JButton addEmployee = new JButton("Add Employee");
    JButton addRoomButton = new JButton("Add Room");
    JButton editRoomButton = new JButton("Change Room Price");
    JButton editEmployeeButton = new JButton("Edit Employee");
    editEmployeeButton.setVisible(false);
    JButton deleteEmployeeButton = new JButton("Delete Employee");
    deleteEmployeeButton.setVisible(false);

    JPanel managerBottomPanel = new JPanel();
    managerBottomPanel.add(listRoomsButton);
    managerBottomPanel.add(displayEmployeesButton);
    managerBottomPanel.add(displayTotalButton);
    managerBottomPanel.add(managerLogoutButton);
    managerframe.add(managerBottomPanel, BorderLayout.SOUTH);

    JPanel managerTopPanel = new JPanel();
    managerTopPanel.add(addEmployee);
    managerTopPanel.add(addRoomButton);
    managerTopPanel.add(editRoomButton);
    managerTopPanel.add(editEmployeeButton);
    managerTopPanel.add(deleteEmployeeButton);
    managerframe.add(managerTopPanel, BorderLayout.NORTH);

    addRoomButton.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent event) {
            editEmployeeButton.setVisible(false);
            deleteEmployeeButton.setVisible(false);
            addOrEditRoom(true, false);
        }
    });

    editRoomButton.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent event) {
            editEmployeeButton.setVisible(false);
            deleteEmployeeButton.setVisible(false);
            addOrEditRoom(false, true);
        }
    });

    addEmployee.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent event) {
            addEmployeeorCustomer(true, false);
        }
    });

    managerLogoutButton.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent event) {
            logout();
            listModel.clear();
            mainframe.dispose();
        }
    });

    listRoomsButton.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent event) {
            editEmployeeButton.setVisible(false);
            deleteEmployeeButton.setVisible(false);
            listModel.clear();
            hotel.displayAllRooms();
        }
    });

    displayEmployeesButton.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent event) {
            listModel.clear();
            hotel.displayEmpList();
            editEmployeeButton.setVisible(true);
            deleteEmployeeButton.setVisible(true);
        }
    });

    editEmployeeButton.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent event) {
            EditEmployee edEmp = new EditEmployee(hotel);
            edEmp.setVisible(true);
        }
    });

    deleteEmployeeButton.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent event) {
            DeleteEmployee delEmp = new DeleteEmployee(hotel);
            delEmp.setVisible(true);
        }
    });

    displayTotalButton.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent event) {
            editEmployeeButton.setVisible(false);
            deleteEmployeeButton.setVisible(false);
            listModel.clear();
            hotel.displayTotalBalance();
        }
    });

    managerframe.setPreferredSize(new Dimension(950, 600));
    managerframe.setVisible(true);

    //tabbed section
    JTabbedPane tabbedPane = new JTabbedPane();

    tabbedPane.addTab("Manager Options", managerframe);
    tabbedPane.setMnemonicAt(0, KeyEvent.VK_1);

    tabbedPane.addTab("Employee Options", frame);
    tabbedPane.setMnemonicAt(1, KeyEvent.VK_2);

    ChangeListener changeListener = new ChangeListener() {
        public void stateChanged(ChangeEvent changeEvent) {
            listModel.clear();
            customerName.setText("");
            start.setText("");
            end.setText("");

        }
    };
    tabbedPane.addChangeListener(changeListener);

    tabbedPane.setTabLayoutPolicy(JTabbedPane.SCROLL_TAB_LAYOUT);

    mainframe.setDefaultCloseOperation(JFrame.DO_NOTHING_ON_CLOSE);
    mainframe.add(tabbedPane, BorderLayout.CENTER);
    mainframe.pack();
    mainframe.setVisible(true);

    mainframe.addWindowListener(new WindowAdapter() {
        @Override
        public void windowClosing(WindowEvent event) {
            logout();
            listModel.clear();
            mainframe.dispose();
        }
    });
}

From source file:influent.server.utilities.DateRangeBuilder.java

License:MIT License

public static FL_DateRange getDateRange(DateTime startDate, DateTime endDate) {

    if (startDate == null || endDate == null) {
        return null;
    }//from   ww  w  .j  a va  2 s .  com

    // TODO: add support for numIntervalsPerBin, but on the client resource side in charts only.
    Days days = Days.daysBetween(startDate, endDate);
    if (days.getDays() == 14) {
        return new ConstrainedDateRange(startDate, FL_DateInterval.DAYS, 14L);
    }
    //      if (days.getDays() == 30) { return new ConstrainedDateRange(startDate, FL_DateInterval.DAYS, 15L, 2); }
    //      if (days.getDays() == 60) { return new ConstrainedDateRange(startDate, FL_DateInterval.DAYS, 15L, 4); }
    Weeks weeks = Weeks.weeksBetween(startDate, endDate);
    if (weeks.getWeeks() == 16) {
        return new ConstrainedDateRange(startDate, FL_DateInterval.WEEKS, 16L);
    }
    //      if (weeks.getWeeks() == 32) { return new ConstrainedDateRange(startDate, FL_DateInterval.WEEKS, 16L, 2); }
    Months months = Months.monthsBetween(startDate, endDate);
    if (months.getMonths() == 12) {
        return new ConstrainedDateRange(startDate, FL_DateInterval.MONTHS, 12L);
    }
    if (months.getMonths() == 16) {
        return new ConstrainedDateRange(startDate, FL_DateInterval.MONTHS, 16L);
    }
    //      if (months.getMonths() == 24) { return new ConstrainedDateRange(startDate, FL_DateInterval.MONTHS, 16L, 2); }
    if (months.getMonths() == 32) {
        return new ConstrainedDateRange(startDate, FL_DateInterval.QUARTERS, 12L);
    }
    Years years = Years.yearsBetween(startDate, endDate);
    if (years.getYears() == 4) {
        return new ConstrainedDateRange(startDate, FL_DateInterval.QUARTERS, 16L);
    }
    //      if (years.getYears() == 8) { return new ConstrainedDateRange(startDate, FL_DateInterval.QUARTERS, 16L, 2); }
    if (years.getYears() == 16) {
        return new ConstrainedDateRange(startDate, FL_DateInterval.YEARS, 16L);
    }

    throw new RuntimeException("Unsupported chart date range: " + startDate + " to " + endDate);
}

From source file:influent.server.utilities.DateRangeBuilder.java

License:MIT License

public static FL_DateRange getBigChartDateRange(DateTime startDate, DateTime endDate) {
    if (startDate == null || endDate == null) {
        return null;
    }/*from   w ww.  j a  va2  s.  c  o m*/

    Days days = Days.daysBetween(startDate, endDate);
    if (days.getDays() <= 14) {
        return new ConstrainedDateRange(startDate, FL_DateInterval.DAYS, 14L);
    }
    if (days.getDays() <= 30) {
        return new ConstrainedDateRange(startDate, FL_DateInterval.DAYS, 30L);
    }
    if (days.getDays() <= 60) {
        return new ConstrainedDateRange(startDate, FL_DateInterval.DAYS, 60L);
    }
    Weeks weeks = Weeks.weeksBetween(startDate, endDate);
    if (weeks.getWeeks() <= 16) {
        return new ConstrainedDateRange(startDate, FL_DateInterval.DAYS, 112L);
    }
    if (weeks.getWeeks() <= 32) {
        return new ConstrainedDateRange(startDate, FL_DateInterval.WEEKS, 32L);
    }
    Months months = Months.monthsBetween(startDate, endDate);
    if (months.getMonths() <= 12) {
        return new ConstrainedDateRange(startDate, FL_DateInterval.WEEKS, 52);
    }
    if (months.getMonths() <= 16) {
        return new ConstrainedDateRange(startDate, FL_DateInterval.WEEKS, 70L);
    }
    if (months.getMonths() <= 24) {
        return new ConstrainedDateRange(startDate, FL_DateInterval.MONTHS, 24L);
    }
    if (months.getMonths() <= 32) {
        return new ConstrainedDateRange(startDate, FL_DateInterval.MONTHS, 32L);
    }
    Years years = Years.yearsBetween(startDate, endDate);
    if (years.getYears() <= 4) {
        return new ConstrainedDateRange(startDate, FL_DateInterval.MONTHS, 48L);
    }
    if (years.getYears() <= 5) {
        return new ConstrainedDateRange(startDate, FL_DateInterval.MONTHS, 60L);
    }
    if (years.getYears() <= 6) {
        return new ConstrainedDateRange(startDate, FL_DateInterval.MONTHS, 72L);
    }
    if (years.getYears() <= 7) {
        return new ConstrainedDateRange(startDate, FL_DateInterval.MONTHS, 84L);
    }
    if (years.getYears() <= 8) {
        return new ConstrainedDateRange(startDate, FL_DateInterval.MONTHS, 96L);
    }
    if (years.getYears() <= 16) {
        return new ConstrainedDateRange(startDate, FL_DateInterval.QUARTERS, 64L);
    }

    throw new RuntimeException("Unsupported chart date range: " + startDate + " to " + endDate);
}

From source file:influent.server.utilities.DateRangeBuilder.java

License:MIT License

public static int determineInterval(DateTime date, DateTime startDate, FL_DateInterval interval,
        int numIntervalsPerBin) {
    switch (interval) {
    case SECONDS:
        Seconds seconds = Seconds.secondsBetween(startDate, date);
        return seconds.getSeconds() / numIntervalsPerBin;
    case HOURS://from  www .ja  va 2  s  . com
        Hours hours = Hours.hoursBetween(startDate, date);
        return hours.getHours() / numIntervalsPerBin;
    case DAYS:
        Days days = Days.daysBetween(startDate, date);
        return days.getDays() / numIntervalsPerBin;
    case WEEKS:
        Weeks weeks = Weeks.weeksBetween(startDate, date);
        return weeks.getWeeks() / numIntervalsPerBin;
    case MONTHS:
        Months months = Months.monthsBetween(startDate, date);
        return months.getMonths() / numIntervalsPerBin;
    case QUARTERS:
        months = Months.monthsBetween(startDate, date);
        return months.getMonths() / 3 / numIntervalsPerBin;
    case YEARS:
        Years years = Years.yearsBetween(startDate, date);
        return years.getYears() / numIntervalsPerBin;
    }
    return 0;
}

From source file:info.interactivesystems.spade.similarity.MissingCategoriesResolver.java

License:Apache License

private Integer calculateDifference(Date reviewDate, Date reviewDate2) {
    Integer days = Days.daysBetween(new DateTime(reviewDate), new DateTime(reviewDate2)).getDays();
    if (days < 0) {
        days = days * -1;/*  w  w w  . ja  v a 2  s . c o  m*/
    }
    return days;
}

From source file:info.matchingservice.dom.Match.ProfileMatchingService.java

License:Apache License

/**
 * Returns a comparison between a demand TimePeriod element and a supply UseTimePeriod element
 * Calculation is 'optimistic': when there are no start- or enddates on the supply profile availability is assumed  when Use Time Period exists and is set to true
 * //from   ww  w  .  j  a  v a2s.  c  o m
 * Both start and endDate on the demand profile Time Period element are obligatory
 * 
 * @param demandProfileElement
 * @param supplyProfile
 * @return
 */
@Programmatic
public ProfileElementComparison getProfileElementTimePeriodComparison(
        final ProfileElementTimePeriod demandProfileElement,
        final ProfileElementUsePredicate supplyProfileElement) {

    // return null if types are not as expected
    if (demandProfileElement.getProfileElementType() != ProfileElementType.TIME_PERIOD

            ||

            supplyProfileElement.getProfileElementType() != ProfileElementType.USE_TIME_PERIOD

    ) {
        return null;
    }

    Integer matchValue = 0;

    // When supply profile dates are meant to be used, indicated by supplyProfileElement.getUseTimePeriod() == true
    if (supplyProfileElement.getUseTimePeriod()) {

        // Default for supply with Use Time Period set to true
        matchValue = 100;

        // if the endDate on demandProfile element is there and the startDate on supplyProfile also
        // and if startdate later than enddate value = 0;
        // 
        //   (pic)
        //    demand -------------------*enddate* xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
        //   supply xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx *startdate* ----------------
        if (supplyProfileElement.getProfileElementOwner().getProfileStartDate() != null && supplyProfileElement
                .getProfileElementOwner().getProfileStartDate().isAfter(demandProfileElement.getEndDate())

        ) {
            matchValue = 0;

            System.out.println(
                    "match from getProfileElementTimePeriodComparison() in ProfileMatchingService.class:");
            System.out.println(supplyProfileElement.getProfileElementOwner().getActorOwner().toString()
                    + " >> start supply later than end demand");

        }

        // if the startDate on demandProfile element is there and the endDate on supplyProfile also
        // and if startdate later than enddate value = 0;
        //
        //    (pic)
        //    demand xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx *startdate* ----------------
        //    supply -------------------*enddate* xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx

        if (supplyProfileElement.getProfileElementOwner().getProfileEndDate() != null && demandProfileElement
                .getStartDate().isAfter(supplyProfileElement.getProfileElementOwner().getProfileEndDate())

        ) {
            matchValue = 0;

            System.out.println(
                    "match from getProfileElementTimePeriodComparison() in ProfileMatchingService.class:");
            System.out.println(supplyProfileElement.getProfileElementOwner().getActorOwner().toString()
                    + " >> end supply before start demand");
        }

        // if supply start <= demand start and supply end <= demand end
        // calculate relative value
        //
        //   (pic)
        //    demand xxxxxxxxxxxxxxxxxxx *startdate* ------------------------------- *enddate* xxxxxxxxxxxxxxxxxxxxxxxxx
        //    supply xxxxxx[*startdate*] ----------------------------- *enddate* xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx

        if ((supplyProfileElement.getProfileElementOwner().getProfileEndDate() != null
                && supplyProfileElement.getProfileElementOwner().getProfileEndDate()
                        .isBefore(demandProfileElement.getEndDate().plusDays(1)))
                && ((supplyProfileElement.getProfileElementOwner().getProfileStartDate() != null
                        && supplyProfileElement.getProfileElementOwner().getProfileStartDate()
                                .isBefore(demandProfileElement.getStartDate().plusDays(1)))
                        || (supplyProfileElement.getProfileElementOwner().getProfileStartDate() == null))) {

            final int demandDays = Days
                    .daysBetween(demandProfileElement.getStartDate(), demandProfileElement.getEndDate())
                    .getDays();
            final int deltaDays = Days
                    .daysBetween(supplyProfileElement.getProfileElementOwner().getProfileEndDate(),
                            demandProfileElement.getEndDate())
                    .getDays();

            final double value = 100 * (1 - (double) deltaDays / (double) demandDays);

            matchValue = (int) value;

        }

        // if supply start > demand start and supply end > demand end
        // calculate relative value
        //
        //   (pic)
        //    demand xxxxxxxx *startdate* ------------------------------- *enddate* xxxxxxxxxxxxxxxxxxxxxxxxx
        //    supply xxxxxxxxxxxxxxxxxxxxxxxx*startdate* ----------------------------- [*enddate*] xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
        if (

        (supplyProfileElement.getProfileElementOwner().getProfileStartDate() != null
                && supplyProfileElement.getProfileElementOwner().getProfileStartDate()
                        .isAfter(demandProfileElement.getStartDate().minusDays(1)))
                && ((supplyProfileElement.getProfileElementOwner().getProfileEndDate() != null
                        && supplyProfileElement.getProfileElementOwner().getProfileEndDate()
                                .isAfter(demandProfileElement.getEndDate().minusDays(1)))
                        || (supplyProfileElement.getProfileElementOwner().getProfileEndDate() == null))

        ) {

            final int demandDays = Days
                    .daysBetween(demandProfileElement.getStartDate(), demandProfileElement.getEndDate())
                    .getDays();
            final int deltaDays = Days.daysBetween(demandProfileElement.getStartDate(),
                    supplyProfileElement.getProfileElementOwner().getProfileStartDate()).getDays();

            final double value = 100 * (1 - (double) deltaDays / (double) demandDays);

            matchValue = (int) value;

        }

        // if supply start > demand start and supply end < demand end
        // calculate relative value
        //
        //   (pic)
        //    demand xxxxxxxx *startdate* -------------------------------------------------------------- *enddate* xxxxxxxxxxxxxxxxxxxxxxxxx
        //    supply xxxxxxxxxxxxxxxxxxxxxxxx*startdate* ----------------------------- *enddate* xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
        if (

        supplyProfileElement.getProfileElementOwner().getProfileStartDate() != null
                && supplyProfileElement.getProfileElementOwner().getProfileEndDate() != null
                && supplyProfileElement.getProfileElementOwner().getProfileStartDate()
                        .isAfter(demandProfileElement.getStartDate())
                && supplyProfileElement.getProfileElementOwner().getProfileEndDate()
                        .isBefore(demandProfileElement.getEndDate().plusDays(1))

        ) {

            final int demandDays = Days
                    .daysBetween(demandProfileElement.getStartDate(), demandProfileElement.getEndDate())
                    .getDays();
            final int deltaDays = Days
                    .daysBetween(demandProfileElement.getStartDate(),
                            supplyProfileElement.getProfileElementOwner().getProfileStartDate())
                    .getDays()
                    + Days.daysBetween(supplyProfileElement.getProfileElementOwner().getProfileEndDate(),
                            demandProfileElement.getEndDate()).getDays();

            final double value = 100 * (1 - (double) deltaDays / (double) demandDays);

            matchValue = (int) value;

            System.out.println("value: " + value);
            System.out.println(
                    "match from getProfileElementTimePeriodComparison() in ProfileMatchingService.class:");
            System.out.println(supplyProfileElement.getProfileElementOwner().getActorOwner().toString()
                    + " >> start supply after start demand and end supply before end demand");
            System.out.println("matchValue:  " + matchValue);
            System.out.println("demand:  " + demandProfileElement.getStartDate().toString() + " - "
                    + demandProfileElement.getEndDate().toString());
            System.out.println("supply:  "
                    + supplyProfileElement.getProfileElementOwner().getProfileStartDate().toString() + " - "
                    + supplyProfileElement.getProfileElementOwner().getProfileEndDate().toString());
            System.out.println("demandDays: " + demandDays + "  deltaDays: " + deltaDays);

        }

    }

    ProfileElementComparison profileElementComparison = new ProfileElementComparison(
            demandProfileElement.getProfileElementOwner(), demandProfileElement, supplyProfileElement,
            supplyProfileElement.getProfileElementOwner(),
            supplyProfileElement.getProfileElementOwner().getActorOwner(), matchValue,
            demandProfileElement.getWeight());
    return profileElementComparison;
}

From source file:io.datakernel.aggregation_db.keytype.KeyTypeDate.java

License:Apache License

@Override
public Object fromString(String str) throws ParseException {
    try {/*from   w  w  w .  ja v a  2 s. c  o  m*/
        LocalDate date = LocalDate.parse(str);
        return Days.daysBetween(startDate, date).getDays();
    } catch (IllegalArgumentException e) {
        throw new ParseException("Could not parse date string: '" + str + "'", e);
    }
}

From source file:io.druid.sql.calcite.planner.Calcites.java

License:Apache License

/**
 * Calcite expects "DATE" types to be number of days from the epoch to the UTC date matching the local time fields.
 *
 * @param dateTime joda timestamp//from w  ww.  j  a va 2  s.  com
 * @param timeZone session time zone
 *
 * @return Calcite style date
 */
public static int jodaToCalciteDate(final DateTime dateTime, final DateTimeZone timeZone) {
    final DateTime date = dateTime.withZone(timeZone).dayOfMonth().roundFloorCopy();
    return Days.daysBetween(new DateTime(0L, DateTimeZone.UTC), date.withZoneRetainFields(DateTimeZone.UTC))
            .getDays();
}

From source file:io.github.protino.codewatch.sync.WakatimeDataSyncJob.java

License:Apache License

public void updateNotifications() {
    //Notify goals
    final CountDownLatch firebaseLatch = new CountDownLatch(1);
    final List<GoalItem> goalItemList = new ArrayList<>();
    Context context = getApplicationContext();
    SharedPreferences sharedPreferences = PreferenceManager.getDefaultSharedPreferences(context);

    boolean notifyGoals = sharedPreferences.getBoolean(context.getString(R.string.pref_goal_reminders_key),
            true);/*ww w  .j  a  va  2  s  .  c o  m*/
    boolean notifyRank = sharedPreferences.getBoolean(context.getString(R.string.pref_leaderboard_changes_key),
            true);
    String firebaseUid = sharedPreferences.getString(Constants.PREF_FIREBASE_USER_ID, null);

    String title = context.getString(R.string.app_name);
    Intent resultIntent = new Intent(context, NavigationDrawerActivity.class);
    TaskStackBuilder taskStackBuilder = TaskStackBuilder.create(context);
    taskStackBuilder.addNextIntent(resultIntent);
    PendingIntent pendingIntent = taskStackBuilder.getPendingIntent(0, PendingIntent.FLAG_UPDATE_CURRENT);

    if (notifyGoals && firebaseUid != null) {
        FirebaseDatabase firebaseDatabase = FirebaseDatabase.getInstance();
        DatabaseReference databaseReference = firebaseDatabase.getReference().child("goals").child(firebaseUid);
        databaseReference.addListenerForSingleValueEvent(new ValueEventListener() {
            @Override
            public void onDataChange(DataSnapshot dataSnapshot) {
                for (DataSnapshot snapshot : dataSnapshot.getChildren()) {
                    goalItemList.add(snapshot.getValue(GoalItem.class));
                }
                firebaseLatch.countDown();
            }

            @Override
            public void onCancelled(DatabaseError databaseError) {
                firebaseLatch.countDown();
            }
        });
        try {
            //Build the notification
            NotificationCompat.Builder builder = new NotificationCompat.Builder(context)
                    .setColor(context.getResources().getColor(R.color.colorPrimaryDark))
                    .setSmallIcon(R.mipmap.ic_launcher).setContentTitle(title)
                    .setContentText(context.getString(R.string.goals_reminder));

            firebaseLatch.await();
            NotificationCompat.InboxStyle inboxStyle = new NotificationCompat.InboxStyle();

            for (GoalItem goalItem : goalItemList) {
                String goalText = null;
                switch (goalItem.getType()) {
                case LANGUAGE_GOAL:
                    goalText = context.getString(R.string.language_goal, goalItem.getName(),
                            goalItem.getData());
                    break;
                case PROJECT_DAILY_GOAL:
                    goalText = context.getString(R.string.project_daily_goal, goalItem.getData(),
                            goalItem.getName());
                    break;
                case PROJECT_DEADLINE_GOAL:
                    long deadline = goalItem.getData();
                    long currentDate = System.currentTimeMillis();
                    int remainingDays = Days.daysBetween(new DateTime(currentDate), new DateTime(deadline))
                            .getDays();

                    if (remainingDays > 0) {
                        if (currentDate < deadline) {
                            goalText = context.getString(R.string.finish_project_today, goalItem.getName());
                        }
                    } else {
                        goalText = context.getString(R.string.finish_project_within, goalItem.getName(),
                                remainingDays);
                    }
                    break;
                default:
                    break;
                }
                if (goalText != null) {
                    inboxStyle.addLine(goalText);
                }
            }
            builder.setStyle(inboxStyle);
            builder.setContentIntent(pendingIntent);

            NotificationManager notificationManager = (NotificationManager) context
                    .getSystemService(NOTIFICATION_SERVICE);
            notificationManager.notify(GOAL_NOTIFICATION_ID, builder.build());
        } catch (InterruptedException e) {
            Timber.e(e);
        }
    }

    if (notifyRank) {
        String wakatimeUid = sharedPreferences.getString(PREF_WAKATIME_USER_ID, null);
        Cursor cursor = getContentResolver().query(LeaderContract.LeaderEntry.buildProfileUri(wakatimeUid),
                null, null, null, null);
        if (cursor == null || !cursor.moveToFirst()) {
            return;
        }
        int rank = cursor.getInt(cursor.getColumnIndex(LeaderContract.LeaderEntry.COLUMN_RANK));
        int dailyAverage = cursor
                .getInt(cursor.getColumnIndex(LeaderContract.LeaderEntry.COLUMN_DAILY_AVERAGE));

        String text = context.getString(R.string.leaderboard_notification_text, rank,
                FormatUtils.getFormattedTime(context, dailyAverage));
        NotificationCompat.Builder builder = new NotificationCompat.Builder(context)
                .setSmallIcon(R.mipmap.ic_launcher)
                .setColor(context.getResources().getColor(R.color.colorPrimaryDark)).setContentTitle(title)
                .setContentText(text).setStyle(new NotificationCompat.BigTextStyle().bigText(text))
                .setContentIntent(pendingIntent);
        NotificationManager notificationManager = (NotificationManager) context
                .getSystemService(NOTIFICATION_SERVICE);
        notificationManager.notify(LEADERBOARD_NOTIFICATION_ID, builder.build());
        cursor.close();
    }

}