Format dateFormat = android.text.format.DateFormat.getDateFormat(getApplicationContext()); String pattern = ((SimpleDateFormat) dateFormat).toLocalizedPattern();
SimpleDateFormat sf = (SimpleDateFormat) f; String p1 = sf.toPattern(); String p2 = sf.toLocalizedPattern();
private boolean isMonthFirst(){ SimpleDateFormat format = (SimpleDateFormat)SimpleDateFormat.getDateInstance(SimpleDateFormat.FULL); String pattern = format.toLocalizedPattern(); return pattern.indexOf("M") < pattern.indexOf("d"); }
DateFormat formatter = DateFormat.getDateInstance(DateFormat.SHORT, Locale.getDefault()); String pattern = ((SimpleDateFormat)formatter).toPattern(); String localPattern = ((SimpleDateFormat)formatter).toLocalizedPattern();
/** * Returns a localized pattern string describing this date format. * * @return a localized pattern string describing this date format. */ @Override public String toLocalizedPattern() { if ( compatibleToSuperPattern ) { return super.toLocalizedPattern(); } else { StringBuffer pattern = new StringBuffer( super.toLocalizedPattern() ); int placeholderPosition = replaceHolder( pattern, true ); for ( int i = placeholderPosition; i <= endNanosecondPatternPosition - startNanosecondPatternPosition + placeholderPosition; i++ ) { pattern.insert( i, patternNanosecond ); } return pattern.toString(); } }
return localSimpleDateFormat.get().toLocalizedPattern();
data.daf.applyPattern( field.getFormat() ); } else { data.daf.applyPattern( data.defaultDateFormat.toLocalizedPattern() );
DateFormat fmt = DateFormat.getPatternInstance( DateFormat.YEAR_MONTH, Locale.forLanguageTag("pl-PL")); if (fmt instanceof SimpleDateFormat) { SimpleDateFormat sfmt = (SimpleDateFormat) fmt; String pattern = sfmt.toPattern(); String localizedPattern = sfmt.toLocalizedPattern(); System.out.println(pattern); System.out.println(localizedPattern); }
@Nullable @Override public Option apply(@Nullable String s) { String defaultFormat = new SimpleDateFormat().toLocalizedPattern(); Option o = new Option(s, "as_of_format", true, "The format of the as_of time (only used in conjunction with the as_of option) (Default is: " + defaultFormat + ")"); o.setArgName("format"); o.setRequired(false); return o; } })
String localizedPattern = sdf.toLocalizedPattern() println "country: " + l.getDisplayName(); println "pattern: " + pattern;
/** * @see OpenmrsUtil#getDateFormat(Locale) */ @Test public void getDateFormat_shouldReturnAPatternWithFourYCharactersInIt() { Assert.assertEquals("MM/dd/yyyy", OpenmrsUtil.getDateFormat(Locale.US).toLocalizedPattern()); Assert.assertEquals("dd/MM/yyyy", OpenmrsUtil.getDateFormat(Locale.UK).toLocalizedPattern()); Assert.assertEquals("tt.MM.uuuu", OpenmrsUtil.getDateFormat(Locale.GERMAN).toLocalizedPattern()); Assert.assertEquals("dd-MM-yyyy", OpenmrsUtil.getDateFormat(new Locale("pt", "pt")).toLocalizedPattern()); }
/** * Return a localized pattern string describing this date format. * @stable ICU 2.0 */ public String toLocalizedPattern() { return ((java.text.SimpleDateFormat)dateFormat).toLocalizedPattern(); }
/** * Return a localized pattern string describing this date format. * @stable ICU 2.0 */ public String toLocalizedPattern() { return ((java.text.SimpleDateFormat)dateFormat).toLocalizedPattern(); }
DateFormat f = getDateTimeInstance(FULL, FULL, new Locale("nl_NL")); SimpleDateFormat sf = (SimpleDateFormat) f; String p1 = sf.toPattern(); String p2 = sf.toLocalizedPattern(); System.out.println( p1 ); System.out.println( p2 );
Locale locale = httpServletRequest.getLocale(); final Date currentDate = new Date(); final DateFormat dateInstance = DateFormat.getDateInstance(DateFormat.FULL, locale); final String format = dateInstance.format(currentDate); System.out.println(format); if (dateInstance instanceof SimpleDateFormat) { System.out.println("pattern: " + ((SimpleDateFormat) dateInstance).toPattern()); System.out.println("localized pattern: "+((SimpleDateFormat) dateInstance).toLocalizedPattern()); }
/** * @see org.apache.tapestry.form.translator.AbstractTranslator#getMessageParameters(java.util.Locale, * java.lang.String) */ protected Object[] getMessageParameters(Locale locale, String label) { String pattern = getDateFormat(locale).toLocalizedPattern().toUpperCase(locale); return new Object[] { label, pattern }; }
protected Date convertStringToDate(String s) { try { return dateFormat.parse(s); } catch (ParseException e) { throw new DataImportHandlerException(SEVERE, "Value for " + LAST_INDEX_KEY + " is invalid for date format " + dateFormat.toLocalizedPattern() + " : " + s); } } /**
/** * Returns the localized format, which is used when constructing a datebox. * <p> * You might override this method to provide your own localized format. */ protected String getLocalizedFormat() { return new SimpleDateFormat(getRealFormat(), _locale != null ? _locale : Locales.getCurrent()) .toLocalizedPattern(); }
public String toPattern() { Capturer.capture(Instrumenter.CAPTURE_ID_JAVA_TEXT_SIMPLEDATEFORMAT, this, "toPattern", "()Ljava/lang/String;", new Object[] {}); String ret = super.toLocalizedPattern(); Capturer.enable(Instrumenter.CAPTURE_ID_JAVA_TEXT_SIMPLEDATEFORMAT, this, ret); return ret; }
public String toLocalizedPattern() { Capturer.capture(Instrumenter.CAPTURE_ID_JAVA_TEXT_SIMPLEDATEFORMAT, this, "toLocalizedPattern", "()Ljava/lang/String;", new Object[] {}); String ret = super.toLocalizedPattern(); Capturer.enable(Instrumenter.CAPTURE_ID_JAVA_TEXT_SIMPLEDATEFORMAT, this, ret); return ret; }