Example usage for org.joda.time LocalDate toString

List of usage examples for org.joda.time LocalDate toString

Introduction

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

Prototype

public String toString(String pattern) 

Source Link

Document

Output the date using the specified format pattern.

Usage

From source file:com.ning.billing.invoice.template.formatters.DefaultInvoiceFormatter.java

License:Apache License

@Override
public String getFormattedInvoiceDate() {
    final LocalDate invoiceDate = invoice.getInvoiceDate();
    if (invoiceDate == null) {
        return "";
    } else {/*from   w ww.  j a  v  a  2  s  .  c o m*/
        return Strings.nullToEmpty(invoiceDate.toString(dateFormatter));
    }
}

From source file:com.nitdlibrary.EditBook.java

/**
 * load result set for filtered data and apply model to table
 *//*  ww w .java  2s .  c o  m*/
private void loadFilteredIssueData(LocalDate from, LocalDate to) throws SQLException {

    PreparedStatement query = library.prepareStatement(
            "select issue.issue_id,issue.issuer_id as 'roll_no',student.`First Name`,issue.issue_date,issue.due_date,issue.return_date from issue,student where issue.acc_no = ? and student.roll_no = issue.issuer_id and (issue.issue_date between ? and ?)");
    query.setInt(1, acc);
    query.setString(2, from.toString("yyyy-MM-dd"));
    query.setString(3, to.toString("yyyy-MM-dd"));
    System.out.println(query.toString());
    issueFilteredResultSet = query.executeQuery();
    issueHistoryTable.setModel(DbUtils.resultSetToTableModel(issueFilteredResultSet));
}

From source file:com.nitdlibrary.EditViewStudent.java

/**
 * load result set for filtered data and apply model to table
 *//* w  w  w . ja  va2 s . co m*/
private void loadFilteredIssueData(LocalDate from, LocalDate to) throws SQLException {

    PreparedStatement query = library.prepareStatement(
            "select issue.issue_id,issue.acc_no,books.title,books.author,issue.issue_date,issue.return_date,issue.due_date from issue,books where issue.issuer_id = ? and books.acc_no = issue.acc_no and (issue.issue_date between ? and ?)");
    query.setInt(1, currentRollNo);
    query.setString(2, from.toString("yyyy-MM-dd"));
    query.setString(3, to.toString("yyyy-MM-dd"));
    System.out.println(query.toString());
    issueFilteredResultSet = query.executeQuery();
    issueHistoryTable.setModel(DbUtils.resultSetToTableModel(issueFilteredResultSet));
}

From source file:com.nitdlibrary.ReportGenerator.java

/**
 * This method extracts details from database into result sets and updates fields
 *//*from   w w  w  .j  av a2  s.c o m*/
private void updateView(int issueKey) throws Exception {
    DateFormat format = Config.dateFormat;

    todayLabel.setText("Today's Date : " + (new LocalDate(new java.util.Date())).toString("yyyy-MM-dd"));
    this.issueID = issueKey;
    this.library = NITDLibrary.createConnection();
    PreparedStatement queryIssue = library.prepareStatement("select * from issue where issue_id = ?");
    queryIssue.setInt(1, issueID);
    issue = queryIssue.executeQuery();
    issue.next();
    /**
     * Updating issue related fields
     */
    issueIDLabel.setText((new Integer(issueID).toString()));
    LocalDate issueDateJoda = new LocalDate(issue.getString("issue_date"));
    LocalDate returnDateJoda = null;
    if (issue.getString("return_date") != null) {
        returnDateJoda = new LocalDate(issue.getString("return_date"));
        returnDate.setText(returnDateJoda.toString("dd-MM-yyyy"));
    } else
        returnDate.setText(null);
    //         System.out.println("RETURN DATE : " + returnDateJoda.toString());
    LocalDate dueDateJoda = new LocalDate(issue.getString("due_date"));
    issueDate.setText(issueDateJoda.toString("dd-MM-yyyy"));

    dueDate.setText(dueDateJoda.toString("dd-MM-yyyy"));
    int exceed = Config.daysExceeded(issue.getString("return_date"), issue.getString("due_date"));
    if (exceed < 0)
        exceed = 0;
    exceedSpinner.setValue(exceed);
    fine.setText((new Integer(exceed * Config.ChARGEPERDAY).toString()));
    acc = issue.getInt("acc_no");
    roll = issue.getInt("issuer_id");
    /**
     * Obtaining result sets for books and student
     */
    ResultSet[] holder = Config.getReportData(acc, roll);
    books = holder[0];
    student = holder[1];
    books.next();
    student.next();
    /**
     * updating student fields
     */
    fname.setText(student.getString("First Name"));
    lname.setText(student.getString("Last Name"));
    contactnumber.setText(student.getString("Contact Number"));
    email.setText(student.getString("E-Mail"));
    rollno.setText(student.getString("roll_no"));
    cardno.setText(student.getString("Card Numbers"));
    category.setText(student.getString("Category"));
    programme.setText(student.getString("Programme"));
    branch.setText(student.getString("Branch"));
    /**
     * CHECKING IF STUDENT IS PASSED OUT
     */
    String programmeString = student.getString("Programme");
    if (Config.isPassed(programmeString, student.getInt("Year"))) {
        yearStudent.setText("Passed Out");
    } else {
        yearStudent.setText(student.getString("Year")); // so that when changes are saved data is not lost
    }
    Image image = null;
    try {
        image = ImageIO.read(new File(student.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));

    /**
     * Load details for book
     */
    title.setText(books.getString("title"));
    author1.setText(books.getString("author"));
    author2.setText(books.getString("author2"));
    author3.setText(books.getString("author3"));
    isbn.setText(books.getString("ISBN"));
    publisher.setText(books.getString("publisher"));
    edition.setText(books.getString("edition"));
    price.setText((new Float(books.getFloat("price")).toString()));
    String[] yearFull = books.getString("year").split("[-]");
    year.setText(yearFull[0]);
    pagination.setText((new Integer(books.getInt("pagination")).toString()));

    subjectCombo.setText(books.getString("subject"));

    location.setText(books.getString("location"));
    accNo.setText(books.getString("acc_no"));
    switch (books.getInt("status")) {
    case 0:
        status.setText("None");
        break;
    case 1:
        status.setText("Students");
        break;
    case 2:
        status.setText("Teachers");
        break;
    case 3:
        status.setText("All");
        break;
    }

}

From source file:com.sonicle.webtop.calendar.Service.java

License:Open Source License

public void processGetSchedulerDates(HttpServletRequest request, HttpServletResponse response,
        PrintWriter out) {/*from ww w .java2s .  c o  m*/
    ArrayList<JsSchedulerEventDate> items = new ArrayList<>();

    try {
        UserProfile up = getEnv().getProfile();
        DateTimeZone utz = up.getTimeZone();
        //DateTimeFormatter ymdZoneFmt = DateTimeUtils.createYmdFormatter(utz);

        // Defines boundaries
        String start = ServletUtils.getStringParameter(request, "startDate", true);
        String end = ServletUtils.getStringParameter(request, "endDate", true);
        DateTime fromDate = DateTimeUtils.parseYmdHmsWithZone(start, "00:00:00", up.getTimeZone());
        DateTime toDate = DateTimeUtils.parseYmdHmsWithZone(end, "23:59:59", up.getTimeZone());

        Set<Integer> activeCalIds = getActiveFolderIds();
        List<LocalDate> dates = manager.listEventDates(activeCalIds, fromDate, toDate, utz);
        for (LocalDate date : dates) {
            items.add(new JsSchedulerEventDate(date.toString("yyyy-MM-dd")));
        }
        /*
        List<DateTime> dates = manager.listEventDates(activeCalIds, fromDate, toDate, utz);
        for (DateTime date : dates) {
           items.add(new JsSchedulerEventDate(ymdZoneFmt.print(date)));
        }
        */

        new JsonResult("dates", items).printTo(out);

    } catch (Exception ex) {
        logger.error("Error in GetSchedulerDates", ex);
        new JsonResult(false, "Error").printTo(out);

    }
}

From source file:com.the.todo.parser.DateAndTimeParser.java

License:MIT License

public static String changeDateStringsFormat(String input) {
    String formattedInput = input;
    Pattern pattern = Pattern.compile(
            "(?:(?:31(\\/|-|\\.)(?:0?[13578]|1[02]))\\1|(?:(?:29|30)(\\/|-|\\.)(?:0?[1,3-9]|1[0-2])\\2))(?:(?:1[6-9]|[2-9]\\d)?\\d{2})|\\b(?:29(\\/|-|\\.)0?2\\3(?:(?:(?:1[6-9]|[2-9]\\d)?(?:0[48]|[2468][048]|[13579][26])|(?:(?:16|[2468][048]|[3579][26])00))))|\\b(?:0?[1-9]|1\\d|2[0-8])(\\/|-|\\.)(?:(?:0?[1-9])|(?:1[0-2]))\\4(?:(?:1[6-9]|[2-9]\\d)?\\d{2})");
    Matcher matcher = pattern.matcher(input);

    while (matcher.find()) {
        String matchedDate = matcher.group();
        LocalDate date = LocalDate.parse(matchedDate, DAY_MONTH_YEAR_SLASH);
        formattedInput = formattedInput.replace(matchedDate, date.toString(YEAR_MONTH_DAY_SLASH));
        System.out.println(formattedInput);
    }//from  w  ww .j  av a2s .  co  m

    return formattedInput;
}

From source file:de.appsolve.padelcampus.controller.bookings.BookingsPayMillController.java

private void addPublicApiKeyToModel(ModelAndView directDebitView) {
    PayMillConfig config = payMillConfigDAO.findFirst();
    directDebitView.addObject("PAYMILL_PUBLIC_KEY", config.getPublicApiKey());
    List<String> years = new ArrayList<>();
    LocalDate date = new LocalDate();
    years.add(date.toString("yyyy"));
    int i = 0;/*from   w  w  w.  j  a v a2  s. c om*/
    while (i < 10) {
        date = date.plusYears(1);
        years.add(date.toString("yyyy"));
        i++;
    }
    directDebitView.addObject("Years", years);
}

From source file:eafit.cdei.asignacion.input.Ejemplo.java

/**
 * @param args the command line arguments
 *///  ww w. j a  v a2 s .  c  om
public static void main(String[] args) {
    LocalDate mondayDate = LocalDate.parse("2014-10-20");

    String tmpDay = mondayDate.toString("EEEE");

    DateTimeFormatter date = DateTimeFormat.forPattern("yyyy-mm-dd");
    DateTimeFormatter time = DateTimeFormat.forPattern("hh:mm:ss");

    String day = date.parseDateTime("2015-04-16").dayOfWeek().getAsText();
    System.out.println(tmpDay + "/" + day);
}

From source file:eafit.cdei.asignacion.vo.Teacher.java

public void addCourseAvaliability(List<TimeDayLocation> pt) {
    DateTimeFormatter fmt = DateTimeFormat.forPattern("YY-MM-DDH:mm:ss");
    LocalDate mondayDate = LocalDate.parse("2014-10-20");

    meetTimeIntervals = new ArrayList<>();

    for (TimeDayLocation tdl : pt) {
        String key = tdl.getDow().dayOfWeek().getAsText() + tdl.getTimeStartString() + tdl.getTimeEndString();
        if (!mapCoursesAvaliability.containsKey(key)) {
            getMapCoursesAvaliability().put(key, tdl);
            getListAvaliability().add(tdl);

            for (int x = 0; x <= 6; x++) {
                LocalDate tmpStartDate = mondayDate.plusDays(x);
                String tmpDay = tmpStartDate.toString("EEEE");
                if (tmpStartDate.dayOfWeek().equals(tdl.getDow().dayOfWeek())) {
                    DateTime tmpStartDateTime = DateTime.parse(
                            tmpStartDate.toString("YY-MM-DD") + tdl.getTimeStart().toString("H:mm:ss"), fmt);
                    DateTime tmpStopDateTime = DateTime.parse(
                            tmpStartDate.toString("YY-MM-DD") + tdl.getTimeEnd().toString("H:mm:ss"), fmt);
                    meetTimeIntervals.add(new Interval(tmpStartDateTime, tmpStopDateTime));
                }//from w  w  w  . jav  a  2s  .co m
            }
        }
    }
}

From source file:eafit.cdei.util.IntervalGenerator.java

public static List<Interval> getIntervals(List<String> days, Time startTime, Time stopTime) {
    DateTimeFormatter fmt = DateTimeFormat.forPattern("YY-MM-DDH:mm:ss");

    List<Interval> tmpMeetTimeIntervals = new ArrayList<Interval>();
    LocalDate mondayDate = LocalDate.parse("2014-10-20");
    for (int x = 0; x <= 5; x++) {
        LocalDate tmpStartDate = mondayDate.plusDays(x);
        String tmpDay = tmpStartDate.toString("EEEE");
        if (days.contains(tmpDay)) {
            DateTime tmpStartDateTime = DateTime.parse(
                    tmpStartDate.toString("YY-MM-DD") + LocalTime.fromDateFields(startTime).toString("H:mm:ss"),
                    fmt);//from   www  . j  a  v  a2s.  c o  m
            DateTime tmpStopDateTime = DateTime.parse(
                    tmpStartDate.toString("YY-MM-DD") + LocalTime.fromDateFields(stopTime).toString("H:mm:ss"),
                    fmt);
            tmpMeetTimeIntervals.add(new Interval(tmpStartDateTime, tmpStopDateTime));
        }
    }

    return tmpMeetTimeIntervals;
}