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, Locale locale) throws IllegalArgumentException 

Source Link

Document

Output the date using the specified format pattern.

Usage

From source file:br.com.fidias.chance4j.time.Month.java

License:Open Source License

public static String monthName(int month, MonthOptions options, Locale locale) {
    if (options == null) {
        options = MonthOptions.fullName;
    }//from   ww  w  . jav  a  2 s . co m

    if (locale == null) {
        locale = Locale.getDefault();
    }

    LocalDate date = new LocalDate(1994, month, 1);
    return date.toString(options.getFormat(), locale);
}

From source file:net.sourceforge.fenixedu.presentationTier.docs.academicAdministrativeOffice.RegistryDiploma.java

License:Open Source License

private String getFormatedCurrentDate(String universityName) {
    final StringBuilder result = new StringBuilder();
    LocalDate date = new LocalDate();
    String day = Integer.toString(date.getDayOfMonth());
    String month = date.toString("MMMM", getLocale());
    if (getDocumentRequest().getLanguage().getLanguage().equals(Locale.getDefault().getLanguage())) {
        month = month.toLowerCase();/*  w ww .  ja va2  s .c  om*/
    }
    result.append(universityName).append(", ");
    result.append(day + " ");
    result.append(BundleUtil.getString(Bundle.APPLICATION, getLocale(), "label.of"));
    result.append(" " + month + " ");
    result.append(BundleUtil.getString(Bundle.APPLICATION, getLocale(), "label.of"));
    result.append(" ").append(date.getYear()).append(".");
    return result.toString();
}

From source file:net.sourceforge.fenixedu.presentationTier.docs.academicAdministrativeOffice.RegistryDiploma.java

License:Open Source License

protected String[] getDateByWords(LocalDate date) {

    String day = Integer.toString(date.getDayOfMonth());
    String month = date.toString("MMMM", getLocale());
    if (getDocumentRequest().getLanguage().getLanguage().equals(Locale.getDefault().getLanguage())) {
        month = month.toLowerCase();/*from  w  w  w.ja  v a  2 s.  co m*/
    }
    String year = Integer.toString(date.getYear());
    String finalDate[] = new String[] { day, month, year };
    return finalDate;

}

From source file:net.sourceforge.fenixedu.presentationTier.docs.FenixReport.java

License:Open Source License

protected String verboseDate(LocalDate date) {
    return "dia " + DateI18NUtil.verboseNumber(date.getDayOfMonth()) + " do ms de "
            + date.toString("MMMM", new Locale("pt")) + " de " + DateI18NUtil.verboseNumber(date.getYear());
}

From source file:net.sourceforge.fenixedu.presentationTier.TagLib.messaging.ArchiveTag.java

License:Open Source License

private String renderYear(YearAnnouncementArchiveEntry year) {
    StringBuilder buffer = new StringBuilder();

    boolean first = true;
    for (int i = year.getFirstPostMonth(); i <= 12; i++) {
        MonthAnnouncementArchiveEntry month = year.getEntries().get(i);

        if (month != null && !first) {
            buffer.append(", ");
        }//  w ww.j  a  v a2s.  c o m
        if (month != null && this.getTargetUrl() != null) {
            buffer.append("<a href=\"").append(this.getTargetUrl());
            buffer.append("selectedYear=").append(year.getYear());
            buffer.append("&amp;selectedMonth=").append(month.getMonth());
            buffer.append("\">");
        }
        if (month != null) {
            Locale locale = I18N.getLocale();
            LocalDate localDate = new LocalDate();
            localDate = localDate.withMonthOfYear(month.getMonth());

            buffer.append(localDate.toString("MMM.", locale));
            buffer.append(" (");
            buffer.append(month.getAnnouncementCount());
            buffer.append(")");
            first = false;
        }
        if (month != null && this.getTargetUrl() != null) {
            buffer.append("</a>");
        }
    }
    return buffer.toString();
}

From source file:org.efaps.esjp.ui.dashboard.StatusPanel_Base.java

License:Apache License

@Override
public CharSequence getHtmlSnipplet() throws EFapsException {
    CharSequence ret;//from   ww w.ja v a2 s.c o m
    if (isCached()) {
        ret = getFromCache();
    } else {
        final Map<LocalDate, Set<Long>> values = new TreeMap<>();

        final DateTime startDate = new DateTime().minusDays(getDays());

        final QueryBuilder queryBldr = new QueryBuilder(CICommon.HistoryLogin);
        queryBldr.addWhereAttrGreaterValue(CICommon.HistoryLogin.Created, startDate);
        queryBldr.addOrderByAttributeAsc(CICommon.HistoryLogin.Created);
        final MultiPrintQuery multi = queryBldr.getPrint();
        multi.addAttribute(CICommon.HistoryLogin.Created, CICommon.HistoryLogin.GeneralInstanceLink);
        multi.executeWithoutAccessCheck();
        while (multi.next()) {
            final DateTime created = multi.getAttribute(CICommon.HistoryLogin.Created);
            final LocalDate date = created.toLocalDate();
            final Long gId = multi.getAttribute(CICommon.HistoryLogin.GeneralInstanceLink);
            Set<Long> set;
            if (values.containsKey(date)) {
                set = values.get(date);
            } else {
                set = new HashSet<>();
                values.put(date, set);
            }
            set.add(gId);
        }

        final LineChart chart = new LineChart().setLineLayout(LineLayout.LINES).setWidth(getWidth())
                .setHeight(getHeight());
        final String title = getTitle();
        if (title != null && !title.isEmpty()) {
            chart.setTitle(getTitle());
        }
        final Axis xAxis = new Axis().setName("x").addConfig("rotation", "-45");
        chart.addAxis(xAxis);

        final Serie<Data> serie = new Serie<Data>();
        serie.setName("Usuarios").setMouseIndicator(new MouseIndicator());
        ;
        chart.addSerie(serie);

        final List<Map<String, Object>> labels = new ArrayList<>();
        int idx = 1;
        LocalDate current = startDate.toLocalDate();
        while (current.isBefore(new DateTime().plusDays(1).toLocalDate())) {
            int yVal;
            if (values.containsKey(current)) {
                yVal = values.get(current).size();
            } else {
                yVal = 0;
            }
            final Data data = new Data();
            serie.addData(data);
            data.setYValue(yVal).setXValue(idx);
            final Map<String, Object> labelMap = new HashMap<>();
            labelMap.put("value", idx);
            labelMap.put("text", Util
                    .wrap4String(current.toString(getDateFormat(), Context.getThreadContext().getLocale())));
            labels.add(labelMap);
            idx++;
            current = current.plusDays(1);
        }
        xAxis.setLabels(Util.mapCollectionToObjectArray(labels));
        chart.setOrientation(Orientation.HORIZONTAL_LEGEND_CHART);
        ret = chart.getHtmlSnipplet();
        cache(ret);
    }
    return ret;
}

From source file:org.fenixedu.qubdocs.util.reports.helpers.DateHelper.java

License:Open Source License

public LocalizedString extendedDate(final LocalDate localDate) {
    LocalizedString i18NString = new LocalizedString();
    for (Locale locale : CoreConfiguration.supportedLocales()) {
        String message = BundleUtil.getString("resources.FenixeduQubdocsReportsResources", locale,
                "message.DateHelper.extendedDate", localDate.toString("dd", locale),
                localDate.toString("MMMM", locale), localDate.toString("yyyy", locale));
        i18NString = i18NString.with(locale, message);
    }//from  w w w  .  j  a  va 2 s  .  co  m
    return i18NString;
}

From source file:org.supercsv.cellprocessor.joda.FmtLocalDate.java

License:Apache License

/**
 * {@inheritDoc}/*from w ww  .j  a v  a2 s  .  c  om*/
 */
@Override
protected String format(final LocalDate jodaType, final String pattern, final Locale locale) {
    return jodaType.toString(pattern, locale);
}