Package java.text

Examples of java.text.SimpleDateFormat.applyPattern()


            if (dateParser == null) {
                dateParser = new SimpleDateFormat(format, Locale.US);
                dateParser.setTimeZone(TimeZone.getTimeZone("GMT"));
                dateParser.set2DigitYearStart(startDate);
            } else {
                dateParser.applyPattern(format);                   
            }
            try {
                return dateParser.parse(dateValue);
            } catch (ParseException pe) {
                // ignore this exception, we will try the next format
View Full Code Here


     */
    public void test_applyPatternLjava_lang_String() {
        // Test for method void
        // java.text.SimpleDateFormat.applyPattern(java.lang.String)
        SimpleDateFormat f2 = new SimpleDateFormat("y", new Locale("de", "CH"));
        f2.applyPattern("GyMdkHmsSEDFwWahKz");
        assertEquals("Wrong pattern", "GyMdkHmsSEDFwWahKz", f2.toPattern());

        // test invalid patterns
        try {
            f2.applyPattern("b");
View Full Code Here

        f2.applyPattern("GyMdkHmsSEDFwWahKz");
        assertEquals("Wrong pattern", "GyMdkHmsSEDFwWahKz", f2.toPattern());

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

        try {
View Full Code Here

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

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

        try {
View Full Code Here

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

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

        try {
View Full Code Here

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

        try {
            f2.applyPattern(null);
            fail("Expected NullPointerException for null pattern");
        } catch (NullPointerException e) {
        }
    }
View Full Code Here

    public void test_clone() {
        // Test for method java.lang.Object java.text.SimpleDateFormat.clone()
        SimpleDateFormat f2 = new SimpleDateFormat();
        SimpleDateFormat clone = (SimpleDateFormat) f2.clone();
        assertTrue("Invalid clone", f2.equals(clone));
        clone.applyPattern("y");
        assertTrue("Format modified", !f2.equals(clone));
        clone = (SimpleDateFormat) f2.clone();
        // Date date = clone.get2DigitYearStart();
        // date.setTime(0);
        // assertTrue("Equal after date change: " +
View Full Code Here

        Date d = new Date(1015822800000L);
        SimpleDateFormat df = new SimpleDateFormat("", new Locale("en", "US"));
        df.setTimeZone(TimeZone.getTimeZone("EST"));

        try {
            df.applyPattern("dd MMMM yyyy EEEE");
            String output = df.format(d);
            Date date = df.parse(output);
            assertTrue("Invalid result 1: " + date, d.equals(date));

            df.applyPattern("dd MMMM yyyy F");
View Full Code Here

            df.applyPattern("dd MMMM yyyy EEEE");
            String output = df.format(d);
            Date date = df.parse(output);
            assertTrue("Invalid result 1: " + date, d.equals(date));

            df.applyPattern("dd MMMM yyyy F");
            output = df.format(d);
            date = df.parse(output);
            assertTrue("Invalid result 2: " + date, d.equals(date));

            df.applyPattern("dd MMMM yyyy w");
View Full Code Here

            df.applyPattern("dd MMMM yyyy F");
            output = df.format(d);
            date = df.parse(output);
            assertTrue("Invalid result 2: " + date, d.equals(date));

            df.applyPattern("dd MMMM yyyy w");
            output = df.format(d);
            date = df.parse(output);
            assertTrue("Invalid result 3: " + date, d.equals(date));

            df.applyPattern("dd MMMM yyyy W");
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.