Package com.ibm.icu.text

Examples of com.ibm.icu.text.DateFormat


    /*
     * Test method for 'com.ibm.icu.text.DateFormat.hashCode()'
     */
    public final void testHashCode() {
        DateFormat df = DateFormat.getInstance();
        DateFormat eq = DateFormat.getDateTimeInstance(DateFormat.SHORT, DateFormat.SHORT);
        testEHCS(df, eq, aDF);
    }
View Full Code Here


    /*
     * Test method for 'com.ibm.icu.text.DateFormat.DateFormat(DateFormat)'
     */
    public final void testDateFormat() {
        DateFormat df = new DateFormat(java.text.DateFormat.getInstance());
        assertEquals(DateFormat.getInstance(), df);
    }
View Full Code Here

     * Test method for 'com.ibm.icu.text.DateFormat.setCalendar(Calendar)'
     */
    public final void testSetCalendar() {
        Calendar cal = Calendar.getInstance();
        cal.setTimeZone(TimeZone.getTimeZone("EST"));
        DateFormat df = DateFormat.getTimeInstance(DateFormat.SHORT);
        df.setCalendar(cal);
        assertEquals("8:17 AM", df.format(aDate));
    }
View Full Code Here

     * Test method for 'com.ibm.icu.text.DateFormat.getCalendar()'
     */
    public final void testGetCalendar() {
        Calendar cal = Calendar.getInstance();
        cal.setTimeZone(TimeZone.getTimeZone("EST"));
        DateFormat df = DateFormat.getTimeInstance(DateFormat.SHORT);
        df.setCalendar(cal);
        assertEquals(cal, df.getCalendar());
    }
View Full Code Here

     * Test method for 'com.ibm.icu.text.DateFormat.setNumberFormat(NumberFormat)'
     */
    public final void testSetNumberFormat() {
        // no easy way to test effect of setting the number format
        NumberFormat nf = NumberFormat.getInstance();
        DateFormat df = DateFormat.getTimeInstance(DateFormat.SHORT);
        df.setNumberFormat(nf);
        // note, can't actually USE the dateformat since it changes the calendar
        assertEquals(nf, df.getNumberFormat());
    }
View Full Code Here

    /*
     * Test method for 'com.ibm.icu.text.DateFormat.setTimeZone(TimeZone)'
     */
    public final void testSetTimeZone() {
        DateFormat df = DateFormat.getTimeInstance(DateFormat.SHORT);
        TimeZone tz = TimeZone.getTimeZone("EST");
        df.setTimeZone(tz);
        assertEquals("8:17 AM", df.format(aDate));
    }
View Full Code Here

    /*
     * Test method for 'com.ibm.icu.text.DateFormat.getTimeZone()'
     */
    public final void testGetTimeZone() {
        DateFormat df = DateFormat.getTimeInstance(DateFormat.SHORT);
        TimeZone tz = TimeZone.getTimeZone("EST");
        df.setTimeZone(tz);
        assertEquals(tz, df.getTimeZone());
    }
View Full Code Here

    /*
     * Test method for 'com.ibm.icu.text.DateFormat.setLenient(boolean)'
     */
    public final void testSetLenient() throws Exception {
        DateFormat df = DateFormat.getDateInstance(DateFormat.SHORT);
        df.parse("2/31/90"); // succeeds, default is lenient
        df.setLenient(false);
        try {
            df.parse("2/31/90");
            throw new Exception("strict parse should have failed");
        }
        catch (ParseException e) {
            // ok, this is what we expect
        }
View Full Code Here

    /*
     * Test method for 'com.ibm.icu.text.DateFormat.isLenient()'
     */
    public final void testIsLenient() {
        DateFormat df = DateFormat.getInstance();
        assertTrue(df.isLenient());
        df.setLenient(false);
        assertFalse(df.isLenient());
    }
View Full Code Here

//#endif

        TimeZone PT = TimeZone.getTimeZone("America/Los_Angeles");
        for (j = 0, exp = 0; j < COUNT; ++j) {
            //  String str;
            DateFormat df = dateFormats[j];
            df.setTimeZone(PT);
            logln(" Pattern = " + ((SimpleDateFormat) df).toPattern());
            try {
                logln("  Result = " + df.format(aug13));
            } catch (Exception e) {
                errln("FAIL: " + e);
                e.printStackTrace();
                continue;
            }

            FieldPosition pos;
            String field;

            for (i = 0; i < DateFormat.FIELD_COUNT; ++i, ++exp) {
                pos = new FieldPosition(i);
                buf.setLength(0);
                df.format(aug13, buf, pos);   
                field = buf.substring(pos.getBeginIndex(), pos.getEndIndex());
                assertEquals("pattern#" + j + " field #" + i + " " + DATEFORMAT_FIELD_NAMES[i],
                             EXPECTED[exp], field);
            }

//#if defined(FOUNDATION10) || defined(J2SE13)
//#else
            // FieldPostion initialized by DateFormat.Field trac#6089
            for(i = 0; i < DTFMT_FIELDS.length; i++) {
                // The format method only set position for the first occurrence of
                // the specified field.
                pos = new FieldPosition(DTFMT_FIELDS[i]);
                buf.setLength(0);
                df.format(aug13, buf, pos);
                field = buf.substring(pos.getBeginIndex(), pos.getEndIndex());
                assertEquals("pattern#" + j + " " + DTFMT_FIELDS[i].toString(), EXPECTED_BY_FIELD[j][i], field);
            }
//#endif
        }
View Full Code Here

TOP

Related Classes of com.ibm.icu.text.DateFormat

Copyright © 2018 www.massapicom. 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.