Example usage for org.joda.time.format DateTimeFormatter print

List of usage examples for org.joda.time.format DateTimeFormatter print

Introduction

In this page you can find the example usage for org.joda.time.format DateTimeFormatter print.

Prototype

public String print(ReadablePartial partial) 

Source Link

Document

Prints a ReadablePartial to a new String.

Usage

From source file:dk.dma.epd.common.prototype.model.voct.sardata.DatumLineData.java

License:Apache License

@Override
public String generateHTML() {

    DateTimeFormatter fmt = DateTimeFormat.forPattern("dd MMMM, yyyy, 'at.' HH':'mm");

    // // Generate a html sheet of rapid response calculations
    StringBuilder str = new StringBuilder();
    // String name = "How does this look";
    ///*w  ww  .  j  av  a  2 s . co  m*/
    str.append("<html>");
    str.append("<table >");
    str.append("<tr>");
    str.append("<td align=\"left\" style=\"vertical-align: top;\">");
    str.append("<h1>Search and Rescue - Datum Point</h1>");
    str.append("<hr>");
    str.append("<font size=\"4\">");
    str.append("Time of Last Known Position: " + fmt.print(this.getLKPDate()) + "");
    str.append("<br>Last Known Position: " + this.getLKP().toString() + "</br>");
    str.append("<br>Commence Search Start time: " + fmt.print(this.getCSSDate()) + "</br>");

    str.append(this.getWeatherPoints().get(0).generateHTML());

    str.append("<hr>");
    str.append("<font size=\"4\">");
    str.append("Initial Position Error, X in nautical miles: " + this.getX() + "");
    str.append("<br>SRU Navigational Error, Y in nautical miles: " + this.getY() + "</br>");
    str.append("<br>Safety Factor, Fs: " + this.getSafetyFactor() + "</br>");
    str.append("<hr>");
    str.append("<font size=\"4\">");
    str.append("Search Object: " + LeewayValues.getLeeWayTypes().get(this.getSearchObject()) + "");
    str.append("<br>With value: " + LeewayValues.getLeeWayContent().get(this.getSearchObject()) + "</br>");
    str.append("<hr>");
    str.append("<font size=\"4\">");
    //        str.append("Time Elapsed: " + Formatter.formatHours(timeElasped) + "");
    //        str.append("<br>Applying Leeway and TWC gives a datum of  "
    //                + datum.toString() + "</br>");
    //        str.append("<br>With the following Residual Drift Vector</br>");
    //        str.append("<br>RDV Direction: " + rdvDirection + "</br>");
    //        str.append("<br>RDV Distance: "
    //                + Formatter.formatDouble(rdvDistance, 2) + " nm</br>");
    //        str.append("<br>RDV Speed: " + Formatter.formatDouble(rdvSpeed, 2)
    //                + " kn/h</br>");
    //        str.append("<br>With radius: " + Formatter.formatDouble(radius, 2)
    //                + "nm </br>");
    str.append("<hr>");
    str.append("<font size=\"4\">");
    str.append("Search Area:");
    //        str.append("<br>A: " + A.toString() + "</br>");
    //        str.append("<br>B: " + B.toString() + "</br>");
    //        str.append("<br>C: " + C.toString() + "</br>");
    //        str.append("<br>D: " + D.toString() + "</br>");
    //        str.append("<br>Total Size: "
    //                + Formatter.formatDouble(radius * 2 * radius * 2, 2)
    //                + " nm2</br>");

    str.append("</font>");
    str.append("</td>");
    str.append("</tr>");
    str.append("</table>");
    str.append("</html>");
    //
    // calculationsText.setText(str.toString());
    //
    //

    return str.toString();
}

From source file:dk.dma.epd.common.prototype.model.voct.sardata.DatumPointData.java

License:Apache License

@Override
public String generateHTML() {

    DateTimeFormatter fmt = DateTimeFormat.forPattern("dd MMMM, yyyy, 'at.' HH':'mm");

    // // Generate a html sheet of rapid response calculations
    StringBuilder str = new StringBuilder();
    // String name = "How does this look";
    ///*from  ww w.java 2  s  .co  m*/
    str.append("<html>");
    str.append("<table >");
    str.append("<tr>");
    str.append("<td align=\"left\" style=\"vertical-align: top;\">");
    str.append("<h1>Search and Rescue - Datum Point</h1>");
    str.append("<hr>");
    str.append("<font size=\"4\">");
    str.append("Time of Last Known Position: " + fmt.print(this.getLKPDate()) + "");
    str.append("<br>Last Known Position: " + this.getLKP().toString() + "</br>");
    str.append("<br>Commence Search Start time: " + fmt.print(this.getCSSDate()) + "</br>");

    str.append(this.getWeatherPoints().get(0).generateHTML());

    str.append("<hr>");
    str.append("<font size=\"4\">");
    str.append("Initial Position Error, X in nautical miles: " + this.getX() + "");
    str.append("<br>SRU Navigational Error, Y in nautical miles: " + this.getY() + "</br>");
    str.append("<br>Safety Factor, Fs: " + this.getSafetyFactor() + "</br>");
    str.append("<hr>");
    str.append("<font size=\"4\">");
    str.append("Search Object: " + LeewayValues.getLeeWayTypes().get(this.getSearchObject()) + "");
    str.append("<br>With value: " + LeewayValues.getLeeWayContent().get(this.getSearchObject()) + "</br>");
    str.append("<hr>");
    str.append("<font size=\"4\">");
    str.append("Time Elapsed: " + Formatter.formatHours(timeElasped) + "");

    str.append("<br>Applying Leeway and TWC gives a datum downwind of  " + datumDownWind.toString() + "</br>");
    str.append("<br>With the following Downwind Residual Drift Vector</br>");
    str.append("<br>RDV Downwind Direction: " + rdvDirectionDownWind + "</br>");
    str.append("<br>RDV Downwind Distance: " + Formatter.formatDouble(rdvDistanceDownWind, 2) + " nm</br>");
    str.append("<br>RDV Speed: " + Formatter.formatDouble(rdvSpeedDownWind, 2) + " kn/h</br>");
    str.append("<br>With radius: " + Formatter.formatDouble(radiusDownWind, 2) + "nm </br>");

    str.append("<hr>");
    str.append("<font size=\"4\">");
    str.append("Search Area:");

    str.append("<br>A: " + A.toString() + "</br>");
    str.append("<br>B: " + B.toString() + "</br>");
    str.append("<br>C: " + C.toString() + "</br>");
    str.append("<br>D: " + D.toString() + "</br>");

    double width = Converter.metersToNm(getA().distanceTo(getD(), CoordinateSystem.CARTESIAN));
    double height = Converter.metersToNm(getB().distanceTo(getC(), CoordinateSystem.CARTESIAN));

    str.append("<br>Total Size: " + Formatter.formatDouble(width * height, 2) + " nm2</br>");

    str.append("</font>");
    str.append("</td>");
    str.append("</tr>");
    str.append("</table>");
    str.append("</html>");
    //
    // calculationsText.setText(str.toString());
    //
    //

    return str.toString();
}

From source file:dk.dma.epd.common.prototype.model.voct.sardata.RapidResponseData.java

License:Apache License

@Override
public String generateHTML() {

    DateTimeFormatter fmt = DateTimeFormat.forPattern("dd MMMM, yyyy, 'at.' HH':'mm");

    // // Generate a html sheet of rapid response calculations
    StringBuilder str = new StringBuilder();
    // String name = "How does this look";
    ///*  w w  w  .  j a v a2 s .  co  m*/
    str.append("<html>");
    str.append("<table >");
    str.append("<tr>");
    str.append("<td align=\"left\" style=\"vertical-align: top;\">");
    str.append("<h1>Search and Rescue - Rapid Response</h1>");
    str.append("<hr>");
    str.append("<font size=\"4\">");
    str.append("Time of Last Known Position: " + fmt.print(this.getLKPDate()) + "");
    str.append("<br>Last Known Position: " + this.getLKP().toString() + "</br>");
    str.append("<br>Commence Search Start time: " + fmt.print(this.getCSSDate()) + "</br>");

    str.append(this.getWeatherPoints().get(0).generateHTML());

    str.append("<hr>");
    str.append("<font size=\"4\">");
    str.append("Initial Position Error, X in nautical miles: " + this.getX() + "");
    str.append("<br>SRU Navigational Error, Y in nautical miles: " + this.getY() + "</br>");
    str.append("<br>Safety Factor, Fs: " + this.getSafetyFactor() + "</br>");
    str.append("<hr>");
    str.append("<font size=\"4\">");
    str.append("Search Object: " + LeewayValues.getLeeWayTypes().get(this.getSearchObject()) + "");
    str.append("<br>With value: " + LeewayValues.getLeeWayContent().get(this.getSearchObject()) + "</br>");
    str.append("<hr>");
    str.append("<font size=\"4\">");
    str.append("Time Elapsed: " + Formatter.formatHours(timeElasped) + "");
    str.append("<br>Applying Leeway and TWC gives a datum of  " + datum.toString() + "</br>");
    str.append("<br>With the following Residual Drift Vector</br>");
    str.append("<br>RDV Direction: " + rdvDirection + "</br>");
    str.append("<br>RDV Distance: " + Formatter.formatDouble(rdvDistance, 2) + " nm</br>");
    str.append("<br>RDV Speed: " + Formatter.formatDouble(rdvSpeed, 2) + " kn/h</br>");
    str.append("<br>With radius: " + Formatter.formatDouble(radius, 2) + "nm </br>");
    str.append("<hr>");
    str.append("<font size=\"4\">");
    str.append("Search Area:");
    str.append("<br>A: " + A.toString() + "</br>");
    str.append("<br>B: " + B.toString() + "</br>");
    str.append("<br>C: " + C.toString() + "</br>");
    str.append("<br>D: " + D.toString() + "</br>");
    str.append("<br>Total Size: " + Formatter.formatDouble(radius * 2 * radius * 2, 2) + " nm2</br>");

    str.append("</font>");
    str.append("</td>");
    str.append("</tr>");
    str.append("</table>");
    str.append("</html>");
    //
    // calculationsText.setText(str.toString());
    //
    //

    return str.toString();
}

From source file:dk.nsi.sdm4.ydelse.simulation.RandomDataUtilForTestPurposes.java

License:Open Source License

public String randomCpr() {
    DateTime dayOfBirth = randomTime(oldestBirthDate, youngestBirthDate);

    DateTimeFormatter formatter = DateTimeFormat.forPattern("ddMMyy");

    String datePart = formatter.print(dayOfBirth);

    String numberPart = randomIntegerSequence(4);

    return datePart + numberPart;
}

From source file:dk.nsi.stamdata.cpr.Factories.java

License:Mozilla Public License

private static String sikredeRecordDateString(DateTime date) {
    DateTimeFormatter formatter = DateTimeFormat.forPattern("yyyyMMdd");
    return formatter.print(date);
}

From source file:dk.nsi.stamdata.cpr.pvit.proxy.CprAbbsBodyBuilder.java

License:Mozilla Public License

public String createCprAbbsSoapBody(DateTime since) {
    DateTimeFormatter formatter = ISODateTimeFormat.dateTime();
    String sinceAsString = formatter.print(since);

    String sinceTag = String.format("<%s:since>%s</%s:since>", ABBRIVIATION, sinceAsString, ABBRIVIATION);

    return openTag(ABBRIVIATION, NAMESPACE, TAG_NAME, sinceTag);
}

From source file:dk.teachus.backend.bean.impl.VelocityNotificationBean.java

License:Apache License

public synchronized void sendTeacherNotificationMail() {
    log.info("Start sending notification mails to the teachers");

    List<Teacher> teachers = personDAO.getPersons(Teacher.class);

    for (Teacher teacher : teachers) {
        List<PupilBooking> pupilBookings = bookingDAO.getTeacherNotificationBookings(teacher);

        if (pupilBookings.isEmpty() == false) {
            if (log.isDebugEnabled()) {
                log.debug("Sending mails with booking count: " + pupilBookings.size() + " for teacher: "
                        + teacher.getName());
            }/*from w w w . j  av  a2 s .c o  m*/

            // Create message to the teacher
            MailMessage message = new MailMessage();

            // Sender and recipient
            message.setSender(teacher);
            message.setRecipient(teacher);

            // The locale
            Locale locale = teacher.getLocale();

            // Build up bookingslist and format date
            List<FormattedPupilBooking> pupilBookingList = new ArrayList<FormattedPupilBooking>();
            for (PupilBooking pupilBooking : pupilBookings) {
                FormattedPupilBooking formattedPupilBooking = new FormattedPupilBooking();
                formattedPupilBooking.setPupilBooking(pupilBooking);
                DateTimeFormatter dateFormat = DATE_TIME_FORMAT.withLocale(locale);
                formattedPupilBooking.setFormattedDate(dateFormat.print(pupilBooking.getDate()));
                pupilBookingList.add(formattedPupilBooking);
            }

            // Load properties
            ResourceBundle bundle = ResourceBundle.getBundle(
                    ClassUtils.getAsResourceBundlePath(VelocityNotificationBean.class, "NewBookingsMail"),
                    locale);

            // Subject
            message.setSubject(bundle.getString("subject"));

            // Parse the template
            Map<String, Object> model = new HashMap<String, Object>();
            model.put("followingPupilsHasBookings", bundle.getString("followingPupilsHasBookings"));
            model.put("pupilHeader", bundle.getString("pupilHeader"));
            model.put("dateHeader", bundle.getString("dateHeader"));
            model.put("pupilBookingList", pupilBookingList);
            String template = "";
            try {
                template = velocityBean.mergeTemplate(
                        ClassUtils.getAsResourcePath(VelocityNotificationBean.class, "NewBookingsMail.vm"),
                        model);
            } catch (VelocityException e) {
                throw new RuntimeException(e);
            }

            // Text
            message.setBody(template);
            message.setType(Type.HTML);
            message.setState(MessageState.FINAL);

            messageDAO.save(message);
        }

        // Send mails
        bookingDAO.teacherNotificationMailSent(pupilBookings);
    }
}

From source file:dk.teachus.backend.bean.impl.VelocityNotificationBean.java

License:Apache License

public synchronized void sendPupilNotificationMail() {
    log.info("Start sending notification mails to the pupil");

    Map<Pupil, List<PupilBooking>> pupilNotificationBookings = bookingDAO.getPupilNotificationBookings();

    if (pupilNotificationBookings.isEmpty() == false) {
        for (Pupil pupil : pupilNotificationBookings.keySet()) {
            List<PupilBooking> bookings = pupilNotificationBookings.get(pupil);

            if (log.isDebugEnabled()) {
                log.debug("Sending mail with booking count: " + bookings.size() + " for pupil: "
                        + pupil.getName());
            }//from ww w. j  ava  2  s .c om

            // Create message to the teacher
            MailMessage message = new MailMessage();

            // Sender and recipient
            message.setSender(pupil.getTeacher());
            message.setRecipient(pupil);

            // The locale
            Locale locale = pupil.getTeacher().getLocale();

            // Build up bookingslist and format date
            List<FormattedBooking> bookingList = new ArrayList<FormattedBooking>();
            for (PupilBooking pupilBooking : bookings) {
                FormattedBooking formattedBooking = new FormattedBooking();
                formattedBooking.setLocation(pupilBooking.getPeriod().getLocation());
                DateTimeFormatter dateFormat = DATE_TIME_FORMAT.withLocale(locale);
                formattedBooking.setFormattedDate(dateFormat.print(pupilBooking.getDate()));
                bookingList.add(formattedBooking);
            }

            // Load properties
            ResourceBundle bundle = ResourceBundle.getBundle(
                    ClassUtils.getAsResourceBundlePath(VelocityNotificationBean.class, "NewBookingsMail"),
                    locale);

            // Subject
            message.setSubject(bundle.getString("subject"));

            // Parse the template
            Map<String, Object> model = new HashMap<String, Object>();
            model.put("newBookings", bundle.getString("newBookings"));
            model.put("locationHeader", bundle.getString("locationHeader"));
            model.put("dateHeader", bundle.getString("dateHeader"));
            model.put("bookingList", bookingList);
            model.put("regard", bundle.getString("regard"));
            model.put("from", pupil.getTeacher().getName());

            String template = "";
            try {
                template = velocityBean.mergeTemplate(ClassUtils
                        .getAsResourcePath(VelocityNotificationBean.class, "PupilNotificationMail.vm"), model);
            } catch (VelocityException e) {
                throw new RuntimeException(e);
            }

            // Text
            message.setBody(template);
            message.setType(Type.HTML);
            message.setState(MessageState.FINAL);

            messageDAO.save(message);
        }

        bookingDAO.pupilNotificationMailSent(pupilNotificationBookings);
    }
}

From source file:dk.teachus.frontend.utils.WeekDayChoiceRenderer.java

License:Apache License

@SuppressWarnings("unchecked")
@Override//  w ww .j  a  v  a  2s.  co m
public Object getDisplayValue(Object object) {
    StringBuilder display = new StringBuilder();
    DateTimeFormatter formatter = null;
    if (format == Format.LONG) {
        formatter = Formatters.getFormatWeekDay();
    } else if (format == Format.SHORT) {
        formatter = Formatters.getFormatWeekDayShort();
    }

    if (object != null) {
        if (object instanceof List) {
            DateTime dt = new DateTime();
            List<WeekDay> weekDays = (List<WeekDay>) object;

            for (WeekDay weekDay : weekDays) {
                if (display.length() > 0) {
                    display.append(", "); //$NON-NLS-1$
                }

                dt = dt.withDayOfWeek(weekDay.getYodaWeekDay());
                display.append(formatter.print(dt));

            }
        } else if (object instanceof WeekDay) {
            WeekDay weekDay = (WeekDay) object;
            DateTime dt = new DateTime().withDayOfWeek(weekDay.getYodaWeekDay());
            display.append(formatter.print(dt));
        }
    }

    return display;
}

From source file:easycare.alc.service.report.HstDiagnosticReportBean.java

public String getSignedAt() {
    if (hstSignature == null) {
        return "";
    }/*  ww  w.  ja v a2  s .com*/

    String dateTimeFormat = String.format("%s %s", messageSource.getMessage(JAVA_DATE_FORMAT_KEY),
            messageSource.getMessage(JAVA_CLOCK_TIME_FORMAT_KEY));

    DateTime dateTimeAndZone = timeZoneHelper
            .convertHardwareLocalDateTimeToSystemTZDateTime(hstSignature.getSignedAt());

    DateTimeFormatter formatter = DateTimeFormat.forPattern(dateTimeFormat).withLocale(locale);
    String signedAt = formatter.print(dateTimeAndZone.toLocalDateTime()).toLowerCase();
    String timeZone = dateTimeAndZone.getZone().getShortName(0);

    return messageSource.getMessage(REPORT_PDF_SIGNATURE_SIGNED_AT_KEY, new String[] { signedAt, timeZone });
}