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

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

Introduction

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

Prototype

public DateTimeFormatter withLocale(Locale locale) 

Source Link

Document

Returns a new formatter with a different locale that will be used for printing and parsing.

Usage

From source file:br.com.caelum.vraptor.converter.jodatime.LocaleBasedJodaTimeConverter.java

License:Open Source License

public DateTime convert(String value, DateTimeFormatter formatter) throws ParseException {
    if (isNullOrEmpty(value)) {
        return null;
    }//from w  w  w.j av a  2s. c o m

    return formatter.withLocale(getLocale()).parseDateTime(value);
}

From source file:com.citrix.g2w.webdriver.pages.BasePage.java

License:Open Source License

/**
 * Method used to convert date time object to string date format.
 *
 * @param pattern  (The pattern of the date time parameter)
 * @param dateTime (Date and time format to format)
 * @return formattedDate (formatted date in string)
 *//*from  w  ww .jav  a  2  s  .c o  m*/
public String convertDateTimeObjectToText(final String pattern, final DateTime dateTime) {
    DateTimeFormatter dateFormat = DateTimeFormat.forPattern(pattern);
    String formattedDate = dateFormat.withLocale(this.locale).print(dateTime);
    return formattedDate;
}

From source file:com.citrix.g2w.webdriver.pages.BasePage.java

License:Open Source License

/**
 * Method used to convert string date format to date time object.
 *
 * @param pattern/*from  w  w  w .  j av  a2  s. c  o  m*/
 *            (The pattern of the date time string parameter)
 * @param dateTimeString
 *            (Date and time format in String)
 * @return dateTime (date time object)
 */
public DateTime convertDateTimeTextToObject(final String pattern, final String dateTimeString) {
    DateTimeFormatter format = DateTimeFormat.forPattern(pattern);
    DateTime dateTime = format.withLocale(this.locale).parseDateTime(dateTimeString);
    return dateTime;
}

From source file:com.citrix.g2w.webdriver.pages.BasePage.java

License:Open Source License

/**
 * Method to set the date value.//from   w  ww  .  ja  va2 s.  co  m
 *
 * @param inputId
 *            (id of an element)
 * @param date
 *            (date object)
 */
public void setDate(final String inputId, final DateTime date) {
    DateTimeFormatter fmt = DateTimeFormat
            .forPattern(this.messages.getMessage("date.format.generateReport.startAndEnd", null, this.locale));
    ((JavascriptExecutor) this.driver).executeScript("document.getElementById('" + inputId + "').value = '"
            + fmt.withLocale(this.locale).print(date) + "'");
}

From source file:com.citrix.g2w.webdriver.pages.BasePage.java

License:Open Source License

/**
 * Method used to set start and end dates for custom report generation.
 * //from ww w.  j  av a 2  s . c  o  m
 * @param startDate
 *            (Start date for custom report)
 * @param endDate
 *            (End date for custom report)
 */
public void setDateRangeForReportGeneration(final DateTime startDate, final DateTime endDate) {
    DateTimeFormatter fmt = DateTimeFormat
            .forPattern(this.messages.getMessage("date.format.generateReport.startAndEnd", null, this.locale));
    if (startDate != null) {
        ((JavascriptExecutor) this.driver).executeScript("document.getElementById('from-date').value = '"
                + fmt.withLocale(this.locale).print(startDate) + "'");
    }
    if (endDate != null) {
        ((JavascriptExecutor) this.driver).executeScript("document.getElementById('to-date').value = '"
                + fmt.withLocale(this.locale).print(endDate) + "'");
    }
}

From source file:com.citrix.g2w.webdriver.pages.ScheduleAWebinarPage.java

License:Open Source License

/**
 * Sets the base starting date/*www  .  j  a v a 2 s  . c om*/
 * @param baseDate DateTime
 */
private void setBaseDate(final DateTime baseDate) {
    DateTimeFormatter fmt = DateTimeFormat
            .forPattern(this.messages.getMessage("date.format.mask.dayInWeekMonthDayYear", null, this.locale));
    ((JavascriptExecutor) this.driver)
            .executeScript("document.getElementById('webinarTimesForm.dateTimes_0.baseDate').value = '"
                    + fmt.withLocale(this.locale).print(baseDate) + "'");
}

From source file:com.citrix.g2w.webdriver.pages.ScheduleAWebinarPage.java

License:Open Source License

/**
 * Sets the ending date/*from  www  .j av a 2  s .co m*/
 * @param endDate DateTime
 */
private void setEndDate(final DateTime endDate) {
    DateTimeFormatter fmt = DateTimeFormat
            .forPattern(this.messages.getMessage("date.format.mask.dayInWeekMonthDayYear", null, this.locale));
    ((JavascriptExecutor) this.driver)
            .executeScript("document.getElementById('recurrenceForm.endDate').value = '"
                    + fmt.withLocale(this.locale).print(endDate) + "'");
}

From source file:com.edoli.calendarlms.CalendarPagerView.java

License:Apache License

public void setCurrentCalendar(DateTime date) {
    mDate = date;/*from   ww  w .  ja v  a2  s .c  o  m*/
    mCalendarView.setDate(date);
    mCurrentCalendarView = new CalendarContentView(getContext());
    mCurrentCalendarView.setDate(date);
    mCurrentCalendarView.setCalendarListener(mCalendarListener);

    DateTimeFormatter formatter = DateTimeFormat.forPattern("MMMMMMM yyyy");
    formatter = formatter.withLocale(Locale.ENGLISH);
    String strDate = formatter.print(date);

    mCalendarView.setTitle(strDate);
    mCalendarView.onCalendarChanged(date);

    LayoutParams params = new LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT);
    addView(mCurrentCalendarView, params);
}

From source file:com.helger.datetime.format.PDTFormatter.java

License:Apache License

/**
 * Assign the passed display locale and the default chronology to the passed
 * date time formatter./*from w  w  w. ja  va2 s.c om*/
 *
 * @param aFormatter
 *        The formatter to be modified. May not be <code>null</code>.
 * @param aDisplayLocale
 *        The display locale to be used. May be <code>null</code>.
 * @return The modified date time formatter. Never <code>null</code>.
 */
@Nonnull
public static DateTimeFormatter getWithLocaleAndChrono(@Nonnull final DateTimeFormatter aFormatter,
        @Nullable final Locale aDisplayLocale) {
    return aFormatter.withLocale(aDisplayLocale).withChronology(PDTConfig.getDefaultChronology());
}

From source file:com.hmsinc.epicenter.velocity.DateTimeFormatTool.java

License:Open Source License

/**
 * Checks a string to see if it matches one of the standard DateTimeFormat
 * style patterns: full, long, medium, short, or default.
 *//*from   w w w.  j ava  2s .  c o m*/
private static DateTimeFormatter getDateStyle(String style, Locale locale, DateTimeZone zone) {
    final DateTimeFormatter ret;

    if (style.equalsIgnoreCase("full")) {
        ret = DateTimeFormat.fullDate();
    } else if (style.equalsIgnoreCase("long")) {
        ret = DateTimeFormat.longDate();
    } else if (style.equalsIgnoreCase("medium")) {
        ret = DateTimeFormat.mediumDate();
    } else if (style.equalsIgnoreCase("short")) {
        ret = DateTimeFormat.shortDate();
    } else if (style.equalsIgnoreCase("none")) {
        ret = null;
    } else {
        ret = DateTimeFormat.forPattern(style);
    }

    return ret == null ? null : ret.withLocale(locale).withZone(zone);
}