Package java.text

Examples of java.text.SimpleDateFormat.applyLocalizedPattern()


  harness.check(true);
      }
    try
      {
  format = new SimpleDateFormat(pattern, locale);
  format.applyLocalizedPattern(localizedPattern);
  harness.check(true);
      }
    catch (IllegalArgumentException e)
      {
  harness.debug(e);
View Full Code Here


                df.applyPattern(pattern);
            }
        } else if (format instanceof SimpleDateFormat) {
            final SimpleDateFormat df = (SimpleDateFormat) format;
            if (localized) {
                df.applyLocalizedPattern(pattern);
            } else {
                df.applyPattern(pattern);
            }
        } else if (format instanceof AngleFormat) {
            ((AngleFormat) format).applyPattern(pattern);
View Full Code Here

    public static String formatDateForDisplay(Locale locale, Date date) {
  DateFormat dateFormat = DateFormat.getDateInstance(
      DateFormat.MEDIUM, locale);
  if (dateFormat instanceof SimpleDateFormat) {
      SimpleDateFormat fmt = (SimpleDateFormat)dateFormat;
      fmt.applyLocalizedPattern(fmt.toLocalizedPattern()+TIME_FORMAT);
      return fmt.format(date);
  } else {
      dateFormat = DateFormat.getDateTimeInstance(
    DateFormat.MEDIUM, DateFormat.LONG, locale);
      return dateFormat.format(date);
View Full Code Here

    public static String formatDateForDisplay(Locale locale, Date date) {
        DateFormat dateFormat = DateFormat.getDateInstance(
                DateFormat.MEDIUM, locale);
        if (dateFormat instanceof SimpleDateFormat) {
            SimpleDateFormat fmt = (SimpleDateFormat) dateFormat;
            fmt.applyLocalizedPattern(fmt.toLocalizedPattern() + TIME_FORMAT);
            return fmt.format(date);
        } else {
            dateFormat = DateFormat.getDateTimeInstance(
                    DateFormat.MEDIUM, DateFormat.LONG, locale);
            return dateFormat.format(date);
View Full Code Here

    public static String formatDateForDisplay(Locale locale, Date date) {
  DateFormat dateFormat = DateFormat.getDateInstance(
      DateFormat.MEDIUM, locale);
  if (dateFormat instanceof SimpleDateFormat) {
      SimpleDateFormat fmt = (SimpleDateFormat)dateFormat;
      fmt.applyLocalizedPattern(fmt.toLocalizedPattern()+TIME_FORMAT);
      return fmt.format(date);
  } else {
      dateFormat = DateFormat.getDateTimeInstance(
    DateFormat.MEDIUM, DateFormat.LONG, locale);
      return dateFormat.format(date);
View Full Code Here

     */
    public void test_applyLocalizedPatternLjava_lang_String() {
        // Test for method void
        // java.text.SimpleDateFormat.applyLocalizedPattern(java.lang.String)
        SimpleDateFormat f2 = new SimpleDateFormat("y", new Locale("de", "CH"));
        f2.applyLocalizedPattern("GuMtkHmsSEDFwWahKz");
        String pattern = f2.toPattern();
        assertTrue("Wrong pattern: " + pattern, pattern
                .equals("GyMdkHmsSEDFwWahKz"));

        // test the new "Z" pattern char
View Full Code Here

        assertTrue("Wrong pattern: " + pattern, pattern
                .equals("GyMdkHmsSEDFwWahKz"));

        // test the new "Z" pattern char
        f2 = new SimpleDateFormat("y", new Locale("de", "CH"));
        f2.applyLocalizedPattern("G u M t Z");
        pattern = f2.toPattern();
        assertTrue("Wrong pattern: " + pattern, pattern.equals("G y M d Z"));

        // test invalid patterns
        try {
View Full Code Here

        pattern = f2.toPattern();
        assertTrue("Wrong pattern: " + pattern, pattern.equals("G y M d Z"));

        // test invalid patterns
        try {
            f2.applyLocalizedPattern("b");
            fail("Expected IllegalArgumentException for pattern with invalid pattern letter: b");
        } catch (IllegalArgumentException e) {
        }

        try {
View Full Code Here

            fail("Expected IllegalArgumentException for pattern with invalid pattern letter: b");
        } catch (IllegalArgumentException e) {
        }

        try {
            f2.applyLocalizedPattern("y");
            fail("Expected IllegalArgumentException for pattern with invalid pattern letter: y");
        } catch (IllegalArgumentException e) {
        }

        try {
View Full Code Here

            fail("Expected IllegalArgumentException for pattern with invalid pattern letter: y");
        } catch (IllegalArgumentException e) {
        }

        try {
            f2.applyLocalizedPattern("a '");
            fail("Expected IllegalArgumentException for pattern with unterminated quote: a '");
        } catch (IllegalArgumentException e) {
        }

        try {
View Full Code Here

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.