Package java.text

Examples of java.text.SimpleDateFormat.toPattern()


            }

            try {
                SimpleDateFormat formatter = (SimpleDateFormat) DateFormat.getDateTimeInstance(dateStyle, timeStyle,
                        locale);
                String pattern = formatter.toPattern();
                format = getInstance(pattern, timeZone, locale);
                cDateTimeInstanceCache.put(key, format);

            } catch (ClassCastException ex) {
                throw new IllegalArgumentException("No date time pattern for locale: " + locale);
View Full Code Here


      cal.setTime(df.parse(arg0));
    } catch (ParseException e) {
      if (df instanceof SimpleDateFormat) {
        SimpleDateFormat sdf = (SimpleDateFormat) df;
        throw new IllegalArgumentException("Failed to parse dateTime " + arg0 +
                                            " with pattern " + sdf.toPattern());
      } else {
        throw new IllegalArgumentException("Failed to parse dateTime " + arg0);
      }
    }
    return cal;
View Full Code Here

      cal.setTime(df.parse(arg0));
    } catch (ParseException e) {
      if (df instanceof SimpleDateFormat) {
        SimpleDateFormat sdf = (SimpleDateFormat) df;
        throw new IllegalArgumentException("Failed to parse time " + arg0 +
                                            " with pattern " + sdf.toPattern());
      } else {
        throw new IllegalArgumentException("Failed to parse time " + arg0);
      }
    }
    return cal;
View Full Code Here

      cal.setTime(df.parse(arg0));
    } catch (ParseException e) {
      if (df instanceof SimpleDateFormat) {
        SimpleDateFormat sdf = (SimpleDateFormat) df;
        throw new IllegalArgumentException("Failed to parse date " + arg0 +
                                            " with pattern " + sdf.toPattern());
      } else {
        throw new IllegalArgumentException("Failed to parse date " + arg0);
      }
    }
    return cal;
View Full Code Here

    @Test
    public void testDefaultDateFormats() throws ParseException {
        SimpleDateFormat df = new SimpleDateFormat("MM/dd/yy");
        Person charlie = new Person("Charlie", "Hubbard", new Date(), null, null);
        charlie.setBirthdate(df.parse("03/21/76"));
        DateTransformer transformer = new DateTransformer( df.toPattern() );

        String json = new JSONSerializer().transform(transformer, "birthdate").serialize(charlie);
        Person newUser = new JSONDeserializer<Person>().deserialize(json);

        assertEquals( charlie.getBirthdate(), newUser.getBirthdate() );
View Full Code Here

        FastDateFormat format = (FastDateFormat) cDateInstanceCache.get(key);
        if (format == null) {
            try {
                SimpleDateFormat formatter = (SimpleDateFormat) DateFormat.getDateInstance(style, locale);
                String pattern = formatter.toPattern();
                format = getInstance(pattern, timeZone, locale);
                cDateInstanceCache.put(key, format);
               
            } catch (ClassCastException ex) {
                throw new IllegalArgumentException("No date pattern for locale: " + locale);
View Full Code Here

                locale = Locale.getDefault();
            }

            try {
                SimpleDateFormat formatter = (SimpleDateFormat) DateFormat.getTimeInstance(style, locale);
                String pattern = formatter.toPattern();
                format = getInstance(pattern, timeZone, locale);
                cTimeInstanceCache.put(key, format);
           
            } catch (ClassCastException ex) {
                throw new IllegalArgumentException("No date pattern for locale: " + locale);
View Full Code Here

        FastDateFormat format = (FastDateFormat) cDateTimeInstanceCache.get(key);
        if (format == null) {
            try {
                SimpleDateFormat formatter = (SimpleDateFormat) DateFormat.getDateTimeInstance(dateStyle, timeStyle,
                        locale);
                String pattern = formatter.toPattern();
                format = getInstance(pattern, timeZone, locale);
                cDateTimeInstanceCache.put(key, format);

            } catch (ClassCastException ex) {
                throw new IllegalArgumentException("No date time pattern for locale: " + locale);
View Full Code Here

     * @param locale Locale
     * @return Patter of passed style and locale. i.e "M/d/yy"
     */
    public static String getDateFormatPattern(int style, Locale locale) {
        final SimpleDateFormat df = (SimpleDateFormat) SimpleDateFormat.getDateInstance(style, locale);
        return df.toPattern();
    }

    // -------------------------------------------------------------------------
    //                      D O U B L E
    // -------------------------------------------------------------------------
View Full Code Here

        {

            if(popupDateFormat == null)
            {
                SimpleDateFormat defaultDateFormat = createStandardDateFormat(facesContext);
                popupDateFormat = defaultDateFormat.toPattern();
            }

            StringBuffer jsPopupDateFormat = new StringBuffer();

            for(int i=0;i<popupDateFormat.length();i++)
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.