Examples of GeneralizedTime


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

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

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

    {
        // 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

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

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

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

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

    {
        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

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

     */
    @Test
    public void testCompareTo() throws ParseException
    {
        String gt1 = "20080102121313,999Z";
        GeneralizedTime generalizedTime1 = new GeneralizedTime( gt1 );

        String gt2 = "20080102121314Z";
        GeneralizedTime generalizedTime2 = new GeneralizedTime( gt2 );

        String gt3 = "20080102121314,001Z";
        GeneralizedTime generalizedTime3 = new GeneralizedTime( gt3 );

        assertTrue( generalizedTime1.compareTo( generalizedTime2 ) < 0 );
        assertTrue( generalizedTime1.compareTo( generalizedTime3 ) < 0 );
        assertTrue( generalizedTime2.compareTo( generalizedTime3 ) < 0 );

        assertTrue( generalizedTime2.compareTo( generalizedTime1 ) > 0 );
        assertTrue( generalizedTime3.compareTo( generalizedTime1 ) > 0 );
        assertTrue( generalizedTime3.compareTo( generalizedTime2 ) > 0 );

        assertTrue( generalizedTime1.compareTo( generalizedTime1 ) == 0 );
        assertTrue( generalizedTime2.compareTo( generalizedTime2 ) == 0 );
        assertTrue( generalizedTime3.compareTo( generalizedTime3 ) == 0 );
    }
View Full Code Here

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

     */
    @Test
    public void testEquals() throws ParseException
    {
        String gt1 = "20080102121314Z";
        GeneralizedTime generalizedTime1 = new GeneralizedTime( gt1 );

        String gt2 = "20080102121314Z";
        GeneralizedTime generalizedTime2 = new GeneralizedTime( gt2 );

        String gt3 = "20080102121314,001Z";
        GeneralizedTime generalizedTime3 = new GeneralizedTime( gt3 );

        assertTrue( generalizedTime1.equals( generalizedTime2 ) );
        assertFalse( generalizedTime1.equals( generalizedTime3 ) );
        assertFalse( generalizedTime1.equals( null ) );
    }
View Full Code Here

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

     * when TimeZone has hours < 10 and minutes > 10).
     */
    public void testDIRSHARED29() throws ParseException
    {
        String gt = "20090312123456+0130";
        GeneralizedTime generalizedTime = new GeneralizedTime( gt );
        String result = generalizedTime.toGeneralizedTime();
        assertEquals( gt, result );
    }
View Full Code Here

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

    {
        try
        {
            String prepared = PrepareString.normalize( value, PrepareString.StringType.DIRECTORY_STRING );

            GeneralizedTime time = new GeneralizedTime( prepared );
            String normalized = time.toGeneralizedTime( Format.YEAR_MONTH_DAY_HOUR_MIN_SEC_FRACTION,
                FractionDelimiter.DOT, 3, TimeZoneFormat.Z );

            return normalized;
        }
        catch ( IOException ioe )
View Full Code Here

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

            return ( backendValue == null ? -1 : 1 );
        }

        // Both objects must be stored as String for generalized tim.
        // But we need to normalize the values first.
        GeneralizedTime backendTime;
        try
        {
            String prepared = PrepareString.normalize( backendValue, PrepareString.StringType.DIRECTORY_STRING );
            backendTime = new GeneralizedTime( prepared );
        }
        catch ( IOException ioe )
        {
            throw new IllegalArgumentException( I18n.err( I18n.ERR_04224, backendValue ) );
        }
        catch ( ParseException pe )
        {
            throw new IllegalArgumentException( I18n.err( I18n.ERR_04224, backendValue ) );
        }

        GeneralizedTime assertTime;
        try
        {
            String prepared = PrepareString.normalize( assertValue, PrepareString.StringType.DIRECTORY_STRING );
            assertTime = new GeneralizedTime( prepared );
        }
        catch ( IOException ioe )
        {
            throw new IllegalArgumentException( I18n.err( I18n.ERR_04224, assertValue ) );
        }
View Full Code Here

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

     */
    @Test
    public void testYearMonthDayHourMinDotFractionMinusHourMin() throws ParseException
    {
        String gt = "200801021213.987-1030";
        GeneralizedTime generalizedTime = new GeneralizedTime( gt );
        String result = generalizedTime.toGeneralizedTime();
        assertEquals( gt, result );
    }
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.