Java Code Examples for java.text.SimpleDateFormat#applyLocalizedPattern()

The following examples show how to use java.text.SimpleDateFormat#applyLocalizedPattern() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: DateUtil.java    From Klyph with MIT License 6 votes vote down vote up
private static String getFormattedFullDate(Date date)
{
	SimpleDateFormat dateFormat = (SimpleDateFormat) SimpleDateFormat.getDateInstance(SimpleDateFormat.FULL);
	String pattern = dateFormat.toLocalizedPattern();

	pattern = pattern.replace("E", "");
	pattern = pattern.replace(",", "");
	pattern = pattern.replace("  ", " ");
	pattern = pattern.trim();
	
	dateFormat.applyLocalizedPattern(pattern);

	return dateFormat.format(date);
}
 
Example 2
Source File: MonthView.java    From AlarmOn with Apache License 2.0 5 votes vote down vote up
@NonNull
private String getMonthAndYearString() {
    Locale locale = Locale.getDefault();
    String pattern = "MMMM yyyy";

    if(Build.VERSION.SDK_INT < 18) pattern = getContext().getResources().getString(R.string.mdtp_date_v1_monthyear);
    else pattern = DateFormat.getBestDateTimePattern(locale, pattern);

    SimpleDateFormat formatter = new SimpleDateFormat(pattern, locale);
    formatter.applyLocalizedPattern(pattern);
    mStringBuilder.setLength(0);
    return formatter.format(mCalendar.getTime());
}
 
Example 3
Source File: DayEditor.java    From nebula with Eclipse Public License 2.0 5 votes vote down vote up
/**
 * (non-API) Method initializeColumnHeaders. Called internally when the column
 * header text needs to be updated.
 *
 * @param columns
 *            A LinkedList of CLabels representing the column objects
 */
protected void refreshColumnHeaders(LinkedList<CLabel> columns) {
	Date startDate = getStartDate();
	GregorianCalendar gc = new GregorianCalendar();
	gc.setTime(startDate);

	SimpleDateFormat formatter = new SimpleDateFormat("EE, MMM d");
	formatter.applyLocalizedPattern(formatter.toLocalizedPattern());

	for (Iterator<CLabel> iter = columns.iterator(); iter.hasNext();) {
		CLabel headerLabel = iter.next();
		headerLabel.setText(formatter.format(gc.getTime()));
		gc.add(Calendar.DATE, 1);
	}
}
 
Example 4
Source File: DateUtil.java    From Klyph with MIT License 5 votes vote down vote up
private static SimpleDateFormat getDateFormat()
{
	SimpleDateFormat dateFormat = (SimpleDateFormat) SimpleDateFormat.getDateInstance(SimpleDateFormat.FULL);
	String pattern = dateFormat.toLocalizedPattern();

	pattern = pattern.replace("y", "");
	pattern = pattern.replace("E", "");
	pattern = pattern.replace(",", "");
	pattern = pattern.replace("  ", " ");
	pattern = pattern.trim();

	dateFormat.applyLocalizedPattern(pattern);

	return dateFormat;
}
 
Example 5
Source File: SimpleDateFormatObjectDescription.java    From ccu-historian with GNU General Public License v3.0 5 votes vote down vote up
/**
 * Creates an object based on this description.
 *
 * @return The object.
 */
public Object createObject() {
    final SimpleDateFormat format = (SimpleDateFormat) super.createObject();
    if (getParameter("pattern") != null) {
        format.applyPattern((String) getParameter("pattern"));
    }
    if (getParameter("localizedPattern") != null) {
        format.applyLocalizedPattern((String) getParameter("localizedPattern"));
    }
    return format;
}
 
Example 6
Source File: JRDateLocaleConverter.java    From jasperreports with GNU Lesser General Public License v3.0 5 votes vote down vote up
@Override
protected Object parse(Object value, String pattern) throws ParseException 
{
	SimpleDateFormat formatter = getFormatter(pattern, locale);
	if (pattern != null)
	{
		if (locPattern) {
			formatter.applyLocalizedPattern(pattern);
		}
		else {
			formatter.applyPattern(pattern);
		}
	}
	return formatter.parse((String) value);
}
 
Example 7
Source File: DateUtil.java    From talk-android with MIT License 5 votes vote down vote up
public static String formatLocale(Date date, String format) {
    String result = "";
    if (date != null) {
        SimpleDateFormat dateFormat = new SimpleDateFormat(format);
        dateFormat.applyLocalizedPattern(format);

        try {
            result = dateFormat.format(date);
        } catch (Exception e) {
            e.printStackTrace();
            return result;
        }
    }
    return result;
}
 
Example 8
Source File: Bug4994312.java    From hottub with GNU General Public License v2.0 4 votes vote down vote up
public static void main(String args[]) {
  SimpleDateFormat df = (SimpleDateFormat)
    DateFormat.getDateInstance(DateFormat.DEFAULT, Locale.GERMAN);
  df.applyLocalizedPattern("tt.MM.uuuu");
  System.out.println(df.format(new Date()));
}
 
Example 9
Source File: Bug4994312.java    From jdk8u-dev-jdk with GNU General Public License v2.0 4 votes vote down vote up
public static void main(String args[]) {
  SimpleDateFormat df = (SimpleDateFormat)
    DateFormat.getDateInstance(DateFormat.DEFAULT, Locale.GERMAN);
  df.applyLocalizedPattern("tt.MM.uuuu");
  System.out.println(df.format(new Date()));
}
 
Example 10
Source File: Bug4994312.java    From jdk8u-jdk with GNU General Public License v2.0 4 votes vote down vote up
public static void main(String args[]) {
  SimpleDateFormat df = (SimpleDateFormat)
    DateFormat.getDateInstance(DateFormat.DEFAULT, Locale.GERMAN);
  df.applyLocalizedPattern("tt.MM.uuuu");
  System.out.println(df.format(new Date()));
}
 
Example 11
Source File: Bug4994312.java    From jdk8u_jdk with GNU General Public License v2.0 4 votes vote down vote up
public static void main(String args[]) {
  SimpleDateFormat df = (SimpleDateFormat)
    DateFormat.getDateInstance(DateFormat.DEFAULT, Locale.GERMAN);
  df.applyLocalizedPattern("tt.MM.uuuu");
  System.out.println(df.format(new Date()));
}
 
Example 12
Source File: Bug4994312.java    From openjdk-8 with GNU General Public License v2.0 4 votes vote down vote up
public static void main(String args[]) {
  SimpleDateFormat df = (SimpleDateFormat)
    DateFormat.getDateInstance(DateFormat.DEFAULT, Locale.GERMAN);
  df.applyLocalizedPattern("tt.MM.uuuu");
  System.out.println(df.format(new Date()));
}
 
Example 13
Source File: Bug4994312.java    From openjdk-8-source with GNU General Public License v2.0 4 votes vote down vote up
public static void main(String args[]) {
  SimpleDateFormat df = (SimpleDateFormat)
    DateFormat.getDateInstance(DateFormat.DEFAULT, Locale.GERMAN);
  df.applyLocalizedPattern("tt.MM.uuuu");
  System.out.println(df.format(new Date()));
}
 
Example 14
Source File: Bug4994312.java    From dragonwell8_jdk with GNU General Public License v2.0 4 votes vote down vote up
public static void main(String args[]) {
  SimpleDateFormat df = (SimpleDateFormat)
    DateFormat.getDateInstance(DateFormat.DEFAULT, Locale.GERMAN);
  df.applyLocalizedPattern("tt.MM.uuuu");
  System.out.println(df.format(new Date()));
}
 
Example 15
Source File: Bug4994312.java    From jdk8u-jdk with GNU General Public License v2.0 4 votes vote down vote up
public static void main(String args[]) {
  SimpleDateFormat df = (SimpleDateFormat)
    DateFormat.getDateInstance(DateFormat.DEFAULT, Locale.GERMAN);
  df.applyLocalizedPattern("tt.MM.uuuu");
  System.out.println(df.format(new Date()));
}
 
Example 16
Source File: Bug4994312.java    From openjdk-jdk9 with GNU General Public License v2.0 4 votes vote down vote up
public static void main(String args[]) {
  SimpleDateFormat df = (SimpleDateFormat)
    DateFormat.getDateInstance(DateFormat.DEFAULT, Locale.GERMAN);
  df.applyLocalizedPattern("tt.MM.uuuu");
  System.out.println(df.format(new Date()));
}
 
Example 17
Source File: Bug4994312.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 4 votes vote down vote up
public static void main(String args[]) {
  SimpleDateFormat df = (SimpleDateFormat)
    DateFormat.getDateInstance(DateFormat.DEFAULT, Locale.GERMAN);
  df.applyLocalizedPattern("tt.MM.uuuu");
  System.out.println(df.format(new Date()));
}
 
Example 18
Source File: Bug4994312.java    From openjdk-jdk8u with GNU General Public License v2.0 4 votes vote down vote up
public static void main(String args[]) {
  SimpleDateFormat df = (SimpleDateFormat)
    DateFormat.getDateInstance(DateFormat.DEFAULT, Locale.GERMAN);
  df.applyLocalizedPattern("tt.MM.uuuu");
  System.out.println(df.format(new Date()));
}
 
Example 19
Source File: Bug4994312.java    From jdk8u60 with GNU General Public License v2.0 4 votes vote down vote up
public static void main(String args[]) {
  SimpleDateFormat df = (SimpleDateFormat)
    DateFormat.getDateInstance(DateFormat.DEFAULT, Locale.GERMAN);
  df.applyLocalizedPattern("tt.MM.uuuu");
  System.out.println(df.format(new Date()));
}
 
Example 20
Source File: Bug4994312.java    From TencentKona-8 with GNU General Public License v2.0 4 votes vote down vote up
public static void main(String args[]) {
  SimpleDateFormat df = (SimpleDateFormat)
    DateFormat.getDateInstance(DateFormat.DEFAULT, Locale.GERMAN);
  df.applyLocalizedPattern("tt.MM.uuuu");
  System.out.println(df.format(new Date()));
}