Package org.apache.directory.api.util

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


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


     */
    @Test
    public void testYearMonthDayHourMinSecCommaFractionPlusHour() throws ParseException
    {
        String gt = "20080102121314,987+0100";
        GeneralizedTime generalizedTime = new GeneralizedTime( gt );
        String result = generalizedTime.toGeneralizedTime();
        assertEquals( gt, result );
    }
View Full Code Here

     */
    @Test
    public void testYearMonthDayHourMinSecCommaFractionMinusHourMin() throws ParseException
    {
        String gt = "20080102121314,987-1030";
        GeneralizedTime generalizedTime = new GeneralizedTime( gt );
        String result = generalizedTime.toGeneralizedTime();
        assertEquals( gt, result );
    }
View Full Code Here

        this.value = value;

        // If the initial value is null, we take the current date/time
        if ( this.value == null )
        {
            this.value = new GeneralizedTime( Calendar.getInstance() );
        }
    }
View Full Code Here

        {
            // Removing the fraction from the value
            Calendar calendar = value.getCalendar();
            calendar.set( Calendar.MILLISECOND, 0 );

            value = new GeneralizedTime( calendar );
        }

        // Saving the dialog settings
        ValueEditorsActivator.getDefault().getDialogSettings()
            .put( ValueEditorsConstants.DIALOGSETTING_KEY_DATE_EDITOR_DISCARD_FRACTION,
View Full Code Here

        {
            DateFormat targetFormat = DateFormat.getDateTimeInstance( DateFormat.MEDIUM, DateFormat.LONG );

            try
            {
                GeneralizedTime generalizedTime = new GeneralizedTime( displayValue );
                Date date = generalizedTime.getCalendar().getTime();
                displayValue = targetFormat.format( date ) + " (" + displayValue + ")"; //$NON-NLS-1$ //$NON-NLS-2$
            }
            catch ( ParseException pe )
            {
                // show the raw value in that case
View Full Code Here

        if ( value != null && value instanceof String )
        {
            String s = ( String ) value;

            // Trying to parse the value
            GeneralizedTime generalizedTime = null;
            try
            {
                generalizedTime = "".equals( s ) ? null : new GeneralizedTime( s ); //$NON-NLS-1$
            }
            catch ( ParseException pe )
            {
                // The value could not be parsed correctly

                // Displaying an error window indicating to the user that the value is bogus
                // and asking him if he wants to continue to edit the value with current date and time selected
                if ( MessageDialog.openConfirm( PlatformUI.getWorkbench().getDisplay().getActiveShell(), Messages
                    .getString( "GeneralizedTimeValueEditor.BogusDateAndTimeValue" ), NLS.bind( //$NON-NLS-1$
                    Messages.getString( "GeneralizedTimeValueEditor.TheValueIsBogus" ), new String[] //$NON-NLS-1$
                    { s } ) ) )
                {
                    // Generating today's date and time
                    generalizedTime = new GeneralizedTime( Calendar.getInstance() );
                }
                else
                {
                    return false;
                }
            }

            // Creating and opening the dialog
            GeneralizedTimeValueDialog dialog = new GeneralizedTimeValueDialog( shell, generalizedTime );
            if ( dialog.open() == GeneralizedTimeValueDialog.OK )
            {
                GeneralizedTime newGeneralizedTime = dialog.getGeneralizedTime();

                // Checking if we need to save the generalized time
                // with or without fraction
                if ( newGeneralizedTime.getFraction() == 0 )
                {
                    setValue( newGeneralizedTime.toGeneralizedTimeWithoutFraction() );
                }
                else
                {
                    setValue( newGeneralizedTime.toGeneralizedTime() );
                }

                return true;
            }
        }
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.