Package org.apache.directory.api.util

Examples of org.apache.directory.api.util.GeneralizedTime


     * Testcases from GeneralizedTimeSyntaxCheckerTest#testCorrectCase().
     */
    @Test
    public void testGeneralizedTimeSyntaxCheckerTestCorrectCase() throws ParseException
    {
        new GeneralizedTime( "20061205184527Z" );
        new GeneralizedTime( "20061205184527+0500" );
        new GeneralizedTime( "20061205184527-1234" );
        new GeneralizedTime( "20061205184527.123Z" );
        new GeneralizedTime( "20061205184527,123+0100" );
        new GeneralizedTime( "2006120519Z" );
    }
View Full Code Here


    @Test
    public void testGeneralizedTimeSyntaxCheckerTestErrorCase()
    {
        try
        {
            new GeneralizedTime( "20060005184527Z" );
            fail( "Expected ParseException" );
        }
        catch ( ParseException pe )
        {
            // expected
        }
        try
        {
            new GeneralizedTime( "20061305184527Z" );
            fail( "Expected ParseException" );
        }
        catch ( ParseException pe )
        {
            // expected
        }
        try
        {
            new GeneralizedTime( "20062205184527Z" );
            fail( "Expected ParseException" );
        }
        catch ( ParseException pe )
        {
            // expected
        }
        try
        {
            new GeneralizedTime( "20061200184527Z" );
            fail( "Expected ParseException" );
        }
        catch ( ParseException pe )
        {
            // expected
        }
        try
        {
            new GeneralizedTime( "20061235184527Z" );
            fail( "Expected ParseException" );
        }
        catch ( ParseException pe )
        {
            // expected
        }
        try
        {
            new GeneralizedTime( "20061205604527Z" );
            fail( "Expected ParseException" );
        }
        catch ( ParseException pe )
        {
            // expected
        }
        try
        {
            new GeneralizedTime( "20061205186027Z" );
            fail( "Expected ParseException" );
        }
        catch ( ParseException pe )
        {
            // expected
        }
        try
        {
            new GeneralizedTime( "20061205184561Z" );
            fail( "Expected ParseException" );
        }
        catch ( ParseException pe )
        {
            // expected
        }
        try
        {
            new GeneralizedTime( "20061205184527Z+" );
            fail( "Expected ParseException" );
        }
        catch ( ParseException pe )
        {
            // expected
        }
        try
        {
            new GeneralizedTime( "20061205184527+2400" );
            fail( "Expected ParseException" );
        }
        catch ( ParseException pe )
        {
            // expected
        }
        try
        {
            new GeneralizedTime( "20061205184527+9900" );
            fail( "Expected ParseException" );
        }
        catch ( ParseException pe )
        {
            // expected
        }
        try
        {
            new GeneralizedTime( "20061205184527+1260" );
            fail( "Expected ParseException" );
        }
        catch ( ParseException pe )
        {
            // expected
        }
        try
        {
            new GeneralizedTime( "20061205184527+1299" );
            fail( "Expected ParseException" );
        }
        catch ( ParseException pe )
        {
            // expected
View Full Code Here

    public void testLeapSecond() throws ParseException
    {
        String gt = "20051231235960Z";
        try
        {
            new GeneralizedTime( gt );
            fail( "Expected ParseException" );
        }
        catch ( ParseException pe )
        {
            // expected
View Full Code Here

     */
    @Test
    public void testFebruary29inLeapYear() throws ParseException
    {
        String gt = "20080229000000Z";
        GeneralizedTime generalizedTime = new GeneralizedTime( gt );
        String result = generalizedTime.toGeneralizedTime();
        assertEquals( gt, result );
    }
View Full Code Here

    public void testFebruary29inNonLeapYear() throws ParseException
    {
        String gt = "20070229000000Z";
        try
        {
            new GeneralizedTime( gt );
            fail( "Expected ParseException" );
        }
        catch ( ParseException pe )
        {
            // expected
View Full Code Here

    public void testNull() throws ParseException
    {
        try
        {
            String gt = null;
            new GeneralizedTime( gt );
            fail( "Expected ParseException" );
        }
        catch ( ParseException pe )
        {
            // expected
        }

        try
        {
            Calendar calendar = null;
            new GeneralizedTime( calendar );
            fail( "Expected IllegalArgumentException" );
        }
        catch ( IllegalArgumentException iae )
        {
            // expected
View Full Code Here

    public void testEmpty() throws ParseException
    {
        String gt = "";
        try
        {
            new GeneralizedTime( gt );
            fail( "Expected ParseException" );
        }
        catch ( ParseException pe )
        {
            // expected
View Full Code Here

    {
        // too short year
        String gt = "200";
        try
        {
            new GeneralizedTime( gt );
            fail( "Expected ParseException" );
        }
        catch ( ParseException pe )
        {
            // expected
        }

        // non-digits in year
        gt = "2XX8";
        try
        {
            new GeneralizedTime( gt );
            fail( "Expected ParseException" );
        }
        catch ( ParseException pe )
        {
            // expected
        }

        // too short month
        gt = "20081";
        try
        {
            new GeneralizedTime( gt );
            fail( "Expected ParseException" );
        }
        catch ( ParseException pe )
        {
            // expected
        }

        // non-digits in month
        gt = "20081X";
        try
        {
            new GeneralizedTime( gt );
            fail( "Expected ParseException" );
        }
        catch ( ParseException pe )
        {
            // expected
        }

        // too short day
        gt = "2008122";
        try
        {
            new GeneralizedTime( gt );
            fail( "Expected ParseException" );
        }
        catch ( ParseException pe )
        {
            // expected
        }

        // non-digits in day
        gt = "2008122X";
        try
        {
            new GeneralizedTime( gt );
            fail( "Expected ParseException" );
        }
        catch ( ParseException pe )
        {
            // expected
        }

        // too short hour
        gt = "200812211";
        try
        {
            new GeneralizedTime( gt );
            fail( "Expected ParseException" );
        }
        catch ( ParseException pe )
        {
            // expected
        }

        // non-digits in hour
        gt = "20081221X1";
        try
        {
            new GeneralizedTime( gt );
            fail( "Expected ParseException" );
        }
        catch ( ParseException pe )
        {
            // expected
        }

        // too short minute
        gt = "20081221121";
        try
        {
            new GeneralizedTime( gt );
            fail( "Expected ParseException" );
        }
        catch ( ParseException pe )
        {
            // expected
        }

        // non-digits in minute
        gt = "20081221121X";
        try
        {
            new GeneralizedTime( gt );
            fail( "Expected ParseException" );
        }
        catch ( ParseException pe )
        {
            // expected
        }

        // too short second
        gt = "2008122112131";
        try
        {
            new GeneralizedTime( gt );
            fail( "Expected ParseException" );
        }
        catch ( ParseException pe )
        {
            // expected
        }

        // non-digits in minute
        gt = "2008122112131X";
        try
        {
            new GeneralizedTime( gt );
            fail( "Expected ParseException" );
        }
        catch ( ParseException pe )
        {
            // expected
        }

        // missing time zone
        gt = "2008010212";
        try
        {
            new GeneralizedTime( gt );
            fail( "Expected ParseException" );
        }
        catch ( ParseException pe )
        {
            // expected
        }

        // missing time zone
        gt = "200801021213";
        try
        {
            new GeneralizedTime( gt );
            fail( "Expected ParseException" );
        }
        catch ( ParseException pe )
        {
            // expected
        }

        // missing time zone
        gt = "20080102121314";
        try
        {
            new GeneralizedTime( gt );
            fail( "Expected ParseException" );
        }
        catch ( ParseException pe )
        {
            // expected
        }

        // no digit
        gt = "2008010212X";
        try
        {
            new GeneralizedTime( gt );
            fail( "Expected ParseException" );
        }
        catch ( ParseException pe )
        {
            // expected
        }

        // no digit
        gt = "200801021213X";
        try
        {
            new GeneralizedTime( gt );
            fail( "Expected ParseException" );
        }
        catch ( ParseException pe )
        {
            // expected
        }

        // no digit
        gt = "20080102121314X";
        try
        {
            new GeneralizedTime( gt );
            fail( "Expected ParseException" );
        }
        catch ( ParseException pe )
        {
            // expected
        }

        // missing time zone
        gt = "20080102121314,1";
        try
        {
            new GeneralizedTime( gt );
            fail( "Expected ParseException" );
        }
        catch ( ParseException pe )
        {
            // expected
        }

        // time zone is not last char
        gt = "20080102121314ZX";
        try
        {
            new GeneralizedTime( gt );
            fail( "Expected ParseException" );
        }
        catch ( ParseException pe )
        {
            // expected
        }

        // time zone is not last char
        gt = "20080102121314+0430X";
        try
        {
            new GeneralizedTime( gt );
            fail( "Expected ParseException" );
        }
        catch ( ParseException pe )
        {
            // expected
        }

        // no fraction digit
        gt = "20080102121314,Z";
        try
        {
            new GeneralizedTime( gt );
            fail( "Expected ParseException" );
        }
        catch ( ParseException pe )
        {
            // expected
View Full Code Here

        calendar.set( Calendar.MINUTE, 13 );
        calendar.set( Calendar.SECOND, 14 );
        calendar.set( Calendar.MILLISECOND, 222 );
        calendar.setTimeZone( TimeZone.getTimeZone( "GMT" ) );

        GeneralizedTime generalizedTime = new GeneralizedTime( calendar );
        String result = generalizedTime.toGeneralizedTime();
        assertEquals( "20080102121314.222Z", result );
    }
View Full Code Here

    {
        Calendar calendar = Calendar.getInstance( TimeZone.getTimeZone( "GMT" ) );
        calendar.setTimeInMillis( 123456789000L ); // default format is without millis

        // create form calendar
        GeneralizedTime generalizedTime1 = new GeneralizedTime( calendar );

        // get the string value
        String gt1 = generalizedTime1.toGeneralizedTime();
        Calendar calendar1 = generalizedTime1.getCalendar();

        // create from string value
        GeneralizedTime generalizedTime2 = new GeneralizedTime( gt1 );

        // get the calendar value
        Calendar calendar2 = generalizedTime2.getCalendar();
        String gt2 = generalizedTime2.toGeneralizedTime();

        // assert that all are equal
        assertEquals( calendar, calendar1 );
        assertEquals( calendar, calendar2 );
        assertEquals( calendar1, calendar2 );
View Full Code Here

TOP

Related Classes of org.apache.directory.api.util.GeneralizedTime

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.