List of usage examples for org.joda.time LocalDate LocalDate
public LocalDate(Object instant)
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.mysema.query.sql.types.LocalDateType.java
License:Apache License
@Override public LocalDate getValue(ResultSet rs, int startIndex) throws SQLException { Date date = rs.getDate(startIndex); return date != null ? new LocalDate(date.getTime()) : null; }
From source file:com.ning.billing.analytics.dao.TimeSeriesTupleMapper.java
License:Apache License
@Override public TimeSeriesTuple map(final int index, final ResultSet r, final StatementContext ctx) throws SQLException { return new TimeSeriesTuple(new LocalDate(r.getDate(1)), r.getDouble(2)); }
From source file:com.ning.killbill.zuora.zuora.ZuoraDateUtils.java
License:Apache License
/** * Today's date/*from w w w .ja v a 2 s.c o m*/ * @return Today's date in Zuora's timezone (without time) */ public static DateTime today() { return new LocalDate(ZUORA_TZ).toDateTimeAtStartOfDay(ZUORA_TZ); }
From source file:com.ning.killbill.zuora.zuora.ZuoraDateUtils.java
License:Apache License
/** * Today's day of the month/* w ww. j a v a2 s . c o m*/ * @return Today's day of the month in Zuora's timezone */ public static int dayOfMonth() { return new LocalDate(ZUORA_TZ).getDayOfMonth(); }
From source file:com.nitdlibrary.EditBook.java
public void calculateBookPerformance() throws SQLException { issueResultSet.beforeFirst();/*w w w . j ava2s . co m*/ java.util.Date returnDate = null, dueDate = null; LocalDate returnDateJoda = null, dueDateJoda = null; int totalIssued = 0, returned = 0, fine = 0, currentIssue = 0; int flag = 0; //incremented when today is > due date and return_date is null. it means that some books are not returned and fine calc is shown wrt today while (issueResultSet.next()) { totalIssued++; if (issueResultSet.getString("return_date") != null) returned++; DateFormat format = new SimpleDateFormat("yyyy-MM-dd", Locale.ENGLISH); try { dueDate = format.parse(issueResultSet.getString("due_date")); /** * IF BOOK HAS NOT BEEN RETURNED AND TODAY>DUEDATE .. FINE TO BE PAID IS SHOWN */ if (issueResultSet.getString("return_date") != null && (issueResultSet.getString("return_date").compareTo("") != 0)) { returnDate = format.parse(issueResultSet.getString("return_date")); } else { String tempDate = format.format(new java.util.Date()); returnDate = format.parse(tempDate); if (dueDate.before(returnDate)) // i.e due date before today and book is not returned. flag++; } returnDateJoda = new LocalDate(returnDate); dueDateJoda = new LocalDate(dueDate); } catch (ParseException ex) { Logger.getLogger(EditViewStudent.class.getName()).log(Level.SEVERE, null, ex); } if (dueDate.before(returnDate)) { Days d = Days.daysBetween(returnDateJoda, dueDateJoda); fine += d.getDays(); } if (issueResultSet.getString("return_date") == null || (issueResultSet.getString("return_date").compareTo("") == 0)) { currentIssue++; } } /** * setting values in Labels */ issued.setText("No of times Issued : " + totalIssued); returnedLabel.setText("No of times Returned : " + returned); if (fine < 0) fine = 0; fineLabel.setText("Total Fine Obtained: " + fine); if (currentIssue != 0) currentLabel.setText("Currently issued : Yes"); else currentLabel.setText("Currently issued : No"); if (flag != 0) exceedLabel.setText("*OverDue : " + flag + " student has exceeded due date and has not returned. Assuming he/she retuns today, total fine is being shown."); else exceedLabel.setText("*"); }
From source file:com.nitdlibrary.EditBook.java
/** * THIS FUNCTION CALCULATES DATA FOR FILTERED RESULTSET AND UPDATES THE LABELS * @param from/*from ww w.j a va 2 s . c om*/ * @param to */ private void calculateFilteredPerformance(LocalDate from, LocalDate to) throws SQLException { issueFilteredResultSet.beforeFirst(); java.util.Date returnDate = null, dueDate = null; LocalDate returnDateJoda = null, dueDateJoda = null; int totalIssued = 0, returned = 0, fine = 0, currentIssue = 0; int flag = 0; //incremented when today is > due date and return_date is null. it means that some books are not returned and fine calc is shown wrt today while (issueFilteredResultSet.next()) { totalIssued++; if (issueFilteredResultSet.getString("return_date") != null) returned++; DateFormat format = new SimpleDateFormat("yyyy-MM-dd", Locale.ENGLISH); try { dueDate = format.parse(issueFilteredResultSet.getString("due_date")); /** * IF BOOK HAS NOT BEEN RETURNED AND TODAY>DUEDATE .. FINE TO BE PAID IS SHOWN */ if (issueFilteredResultSet.getString("return_date") != null && (issueFilteredResultSet.getString("return_date").compareTo("") != 0)) { returnDate = format.parse(issueFilteredResultSet.getString("return_date")); } else { String tempDate = format.format(new java.util.Date()); returnDate = format.parse(tempDate); if (dueDate.before(returnDate)) // i.e due date before today and book is not returned. flag++; } returnDateJoda = new LocalDate(returnDate); dueDateJoda = new LocalDate(dueDate); } catch (ParseException ex) { Logger.getLogger(EditViewStudent.class.getName()).log(Level.SEVERE, null, ex); } if (dueDate.before(returnDate)) { Days d = Days.daysBetween(returnDateJoda, dueDateJoda); fine += d.getDays(); } if (issueFilteredResultSet.getString("return_date") == null || (issueFilteredResultSet.getString("return_date").compareTo("") == 0)) { currentIssue++; } } /** * setting values in Labels */ issuedFiltered.setText("No of times Issued : " + totalIssued); returnedFiltered.setText("No of times Returned : " + returned); if (fine < 0) fine = 0; fineFiltered.setText("Total Fine Obtained : " + fine); if (currentIssue != 0) currentFiltered.setText("Remained issued : Yes"); else currentFiltered.setText("Remained issued : No"); // if(flag!=0){ //exceedLabel.setText("* "+ flag +" books have exceeded due date and are not returned. Assuming they are retuned today, total fine is being shown."); // } }
From source file:com.nitdlibrary.EditBook.java
private void applyFilterButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_applyFilterButtonActionPerformed if (from.getDate().after(to.getDate())) JOptionPane.showMessageDialog(null, "The 'to' date should be after the 'from' date"); else {//www .j a v a 2 s. c o m DateFormat format = new SimpleDateFormat("yyyy-MM-dd", Locale.ENGLISH); String fromDate = format.format(from.getDate()); String toDate = format.format(to.getDate()); LocalDate fromDateJoda = new LocalDate(fromDate); LocalDate toDateJoda = new LocalDate(toDate); try { loadFilteredIssueData(fromDateJoda, toDateJoda); calculateFilteredPerformance(fromDateJoda, toDateJoda); } catch (SQLException ex) { Logger.getLogger(EditViewStudent.class.getName()).log(Level.SEVERE, null, ex); } } }
From source file:com.nitdlibrary.EditViewStudent.java
/** * THIS METHOD LOADS VIEW DATA INTO FIELDS AFTER RECIEVING ROLL NO. ALSO CHECKS IF STUDENT IS PASSED OUT OR NOT * @param rollNoForLoad/*from ww w. ja v a 2 s .c o m*/ */ public void loadViewData(int rollNoForLoad) throws SQLException { currentRollNo = rollNoForLoad; try { PreparedStatement query = library.prepareStatement("select * from student where roll_no = ?"); query.setInt(1, rollNoForLoad); System.out.println(query.toString()); loadViewResultSet = query.executeQuery(); loadViewResultSet.next(); } catch (SQLException ex) { successFailure(false, ex.getMessage()); Logger.getLogger(EditViewStudent.class.getName()).log(Level.SEVERE, null, ex); } /** * RESULTSET OBTAINED, UPDATING FIELDS */ fname.setText(loadViewResultSet.getString("First Name")); mname.setText(loadViewResultSet.getString("Middle Name")); lname.setText(loadViewResultSet.getString("Last Name")); fathername.setText(loadViewResultSet.getString("Fathers Name")); categoryMap(); if (loadViewResultSet.getString("Gender").compareTo("Male") == 0) male.setSelected(true); else female.setSelected(true); primary.setText(loadViewResultSet.getString("Primary Address")); mailing.setText(loadViewResultSet.getString("Mailing Address")); contactnumber.setText(loadViewResultSet.getString("Contact Number")); email.setText(loadViewResultSet.getString("E-Mail")); rollno.setText(loadViewResultSet.getString("roll_no")); cardno.setText(loadViewResultSet.getString("Card Numbers")); /** * CHECKING IF STUDENT IS PASSED OUT */ String programme = loadViewResultSet.getString("Programme"); if (Config.isPassed(programme, loadViewResultSet.getInt("Year"))) { year.setVisible(false); sem.setVisible(false); year.setValue(loadViewResultSet.getInt("Year")); sem.setValue(loadViewResultSet.getInt("Semester")); yearLabel.setVisible(false); semLabel.setVisible(false); /** * take care of passing year based on programme */ if (programme.compareTo("B.Tech") == 0) { int passingYear = (new LocalDate(new Date()).getYear() - loadViewResultSet.getInt("Year") + 4); passOutLabel.setText("Passed out in " + passingYear); } else { int passingYear = (new LocalDate(new Date()).getYear() - loadViewResultSet.getInt("Year") + 2); passOutLabel.setText("Passed out in " + passingYear); } } else { year.setValue(loadViewResultSet.getInt("Year")); // so that when changes are saved data is not lost sem.setValue(loadViewResultSet.getInt("Semester")); passOutLabel.setText("Pass Out : No"); } cardsissued.setValue(loadViewResultSet.getInt("Cards Issued")); Date date = null; try { date = new SimpleDateFormat("yyyy-mm-d", Locale.ENGLISH) .parse(loadViewResultSet.getString("Date Of Birth")); } catch (ParseException ex) { Logger.getLogger(EditViewStudent.class.getName()).log(Level.SEVERE, null, ex); } dob.setDate(date); Image image = null; try { image = ImageIO.read(new File(loadViewResultSet.getString("pic_path"))); } catch (IOException ex) { Logger.getLogger(EditViewStudent.class.getName()).log(Level.SEVERE, null, ex); } Image scaledImage = getScaledImage(image, 168, 130); picLabel.setIcon(new ImageIcon(scaledImage)); picLoc = loadViewResultSet.getString("pic_path"); loadIssueData(); calculateStudentPerformance(); }
From source file:com.nitdlibrary.EditViewStudent.java
/** * THIS FUNCTION CALCULATES STUDENT PERFORMCE AND UPDATES FIELDS *//* ww w .jav a2 s. c om*/ private void calculateStudentPerformance() throws SQLException { issueResultSet.beforeFirst(); Date returnDate = null, dueDate = null; LocalDate returnDateJoda = null, dueDateJoda = null; int totalIssued = 0, returned = 0, fine = 0, currentIssue = 0; int flag = 0; //incremented when today is > due date and return_date is null. it means that some books are not returned and fine calc is shown wrt today while (issueResultSet.next()) { totalIssued++; if (issueResultSet.getString("return_date") != null) returned++; DateFormat format = new SimpleDateFormat("yyyy-MM-dd", Locale.ENGLISH); try { dueDate = format.parse(issueResultSet.getString("due_date")); /** * IF BOOK HAS NOT BEEN RETURNED AND TODAY>DUEDATE .. FINE TO BE PAID IS SHOWN */ if (issueResultSet.getString("return_date") != null && (issueResultSet.getString("return_date").compareTo("") != 0)) { returnDate = format.parse(issueResultSet.getString("return_date")); } else { String tempDate = format.format(new Date()); returnDate = format.parse(tempDate); if (dueDate.before(returnDate)) // i.e due date before today and book is not returned. flag++; } returnDateJoda = new LocalDate(returnDate); dueDateJoda = new LocalDate(dueDate); } catch (ParseException ex) { Logger.getLogger(EditViewStudent.class.getName()).log(Level.SEVERE, null, ex); } System.out.println( "DUE DATE : " + dueDateJoda.toString() + " RETURN DATE : " + returnDateJoda.toString()); if (dueDate.before(returnDate)) { Days d = Days.daysBetween(dueDateJoda, returnDateJoda); fine += d.getDays(); System.out.println("Calculting fine"); } if (issueResultSet.getString("return_date") == null || (issueResultSet.getString("return_date").compareTo("") == 0)) { currentIssue++; } } /** * setting values in Labels */ issued.setText("Total Books Issued : " + totalIssued); returnedLabel.setText("Total Books Returned : " + returned); if (fine < 0) fine = 0; fineLabel.setText("Total Fine : " + fine); currentLabel.setText("Currently issued book count : " + currentIssue); if (flag != 0) exceedLabel.setText("* " + flag + " books have exceeded due date and are not returned. Assuming they are retuned today, total fine is being shown."); }