List of usage examples for org.apache.commons.lang3.time FastDateFormat getInstance
public static FastDateFormat getInstance(final String pattern, final Locale locale)
Gets a formatter instance using the specified pattern and locale.
From source file:com.gargoylesoftware.htmlunit.javascript.host.DateCustom.java
/** * Converts a date to a string, returning the "date" portion using the operating system's locale's conventions. * @param context the JavaScript context * @param thisObj the scriptable/*from ww w . jav a 2 s . c om*/ * @param args the arguments passed into the method * @param function the function * @return converted string */ public static String toLocaleDateString(final Context context, final Scriptable thisObj, final Object[] args, final Function function) { final String formatString; final BrowserVersion browserVersion = ((Window) thisObj.getParentScope()).getBrowserVersion(); if (browserVersion.hasFeature(JS_DATE_LOCALE_DATE_SHORT_WITH_SPECIAL_CHARS)) { // [U+200E] -> Unicode Character 'LEFT-TO-RIGHT MARK' formatString = "\u200Edd\u200E.\u200EMM\u200E.\u200Eyyyy"; } else if (browserVersion.hasFeature(JS_DATE_LOCALE_DATE_SHORT)) { formatString = "d.M.yyyy"; } else { formatString = "EEEE, MMMM dd, yyyy"; } final FastDateFormat format = FastDateFormat.getInstance(formatString, getLocale(thisObj)); return format.format(getDateValue(thisObj)); }
From source file:com.loadtesting.showcase.springmvc.model.converter.FastTimeConverter.java
public FastDateFormat getFormat(TimeZone timeZone) { FastDateFormat result = map.get(timeZone); if (result == null) { FastDateFormat newValue = FastDateFormat.getInstance(pattern, timeZone); result = map.putIfAbsent(timeZone, newValue); if (result == null) { result = newValue;/*ww w. j a va2 s .c om*/ } } return result; }
From source file:edu.harvard.iq.safe.lockss.impl.DaemonStatusDataUtil.java
/** * * @param date/*w w w . ja v a 2 s .c o m*/ * @return */ public static String getStdFrmtdTime(Date date) { return FastDateFormat.getInstance("yyyy-MM-dd HH:mm:ss zz", TimeZone.getDefault()).format(date); }
From source file:edu.harvard.iq.safe.lockss.impl.DaemonStatusDataUtil.java
public static String getStdFrmtdTime(Date date, String timezoneId) { return FastDateFormat.getInstance("yyyy-MM-dd HH:mm:ss zz", TimeZone.getTimeZone(timezoneId)).format(date); }
From source file:edu.harvard.iq.safe.lockss.impl.DaemonStatusDataUtil.java
public static String getStdFrmtdTime(Date date, String timestampPattern, String timezoneId) { return FastDateFormat.getInstance(timestampPattern, TimeZone.getTimeZone(timezoneId)).format(date); }
From source file:com.gargoylesoftware.htmlunit.javascript.host.DateCustom.java
/** * Converts a date to a string, returning the "time" portion using the current locale's conventions. * @param context the JavaScript context * @param thisObj the scriptable/*ww w. j a va 2 s . c o m*/ * @param args the arguments passed into the method * @param function the function * @return converted string */ public static String toLocaleTimeString(final Context context, final Scriptable thisObj, final Object[] args, final Function function) { final String formatString; final BrowserVersion browserVersion = ((Window) thisObj.getParentScope()).getWebWindow().getWebClient() .getBrowserVersion(); if (browserVersion.hasFeature(JS_DATE_LOCALE_TIME_WITH_SPECIAL_CHARS)) { // [U+200E] -> Unicode Character 'LEFT-TO-RIGHT MARK' formatString = "\u200EHH\u200E:\u200Emm\u200E:\u200Ess"; } else { formatString = "HH:mm:ss"; } final FastDateFormat format = FastDateFormat.getInstance(formatString, getLocale(thisObj)); return format.format(getDateValue(thisObj)); }
From source file:com.gargoylesoftware.htmlunit.javascript.host.file.File.java
/** * Returns the {@code lastModifiedDate} property. * @return the {@code lastModifiedDate} property *//* w w w . j a v a 2s . co m*/ @JsxGetter public String getLastModifiedDate() { final Date date = new Date(getLastModified()); final BrowserVersion browser = getBrowserVersion(); final Locale locale = new Locale(browser.getSystemLanguage()); if (browser.hasFeature(BrowserVersionFeatures.JS_FILE_SHORT_DATE_FORMAT)) { final FastDateFormat format = FastDateFormat.getInstance(LAST_MODIFIED_DATE_FORMAT_FF, locale); return format.format(date); } final FastDateFormat format = FastDateFormat.getInstance(LAST_MODIFIED_DATE_FORMAT, locale); return format.format(date); }
From source file:com.silverpeas.calendar.DateTime.java
@Override public String toISO8601() { FastDateFormat formatter = FastDateFormat.getInstance(ISO_8601_PATTERN, getTimeZone()); return formatter.format(this); }
From source file:com.silverpeas.calendar.DateTime.java
@Override public String toShortISO8601() { FastDateFormat formatter = FastDateFormat.getInstance(SHORT_ISO_8601_PATTERN, getTimeZone()); return formatter.format(this); }
From source file:com.epam.parso.impl.CSVDataWriterImpl.java
/** * The function to convert a date into a string according to the format used. * * @param currentDate the date to convert. * @param format the string with the format that must belong to the set of * {@link CSVDataWriterImpl#DATE_OUTPUT_FORMAT_STRINGS} mapping keys. * @return the string that corresponds to the date in the format used. *///w ww. j a v a 2 s . co m protected static String convertDateElementToString(Date currentDate, String format) { String valueToPrint = ""; FastDateFormat dateFormat = FastDateFormat.getInstance(DATE_OUTPUT_FORMAT_STRINGS.get(format), TimeZone.getTimeZone("UTC")); if (currentDate.getTime() != 0) { valueToPrint = dateFormat.format(currentDate.getTime()); } return valueToPrint; }