directory-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From seelm...@apache.org
Subject svn commit: r686730 - /directory/studio/trunk/valueeditors/src/main/java/org/apache/directory/studio/valueeditors/time/InPlaceGeneralizedTimeValueEditor.java
Date Mon, 18 Aug 2008 11:42:24 GMT
Author: seelmann
Date: Mon Aug 18 04:42:23 2008
New Revision: 686730

URL: http://svn.apache.org/viewvc?rev=686730&view=rev
Log:
Fix for DIRSTUDIO-293: Use GeneralizedTimeValue from shared-ldap to convert generalized time
syntax to an java.util.Date

Modified:
    directory/studio/trunk/valueeditors/src/main/java/org/apache/directory/studio/valueeditors/time/InPlaceGeneralizedTimeValueEditor.java

Modified: directory/studio/trunk/valueeditors/src/main/java/org/apache/directory/studio/valueeditors/time/InPlaceGeneralizedTimeValueEditor.java
URL: http://svn.apache.org/viewvc/directory/studio/trunk/valueeditors/src/main/java/org/apache/directory/studio/valueeditors/time/InPlaceGeneralizedTimeValueEditor.java?rev=686730&r1=686729&r2=686730&view=diff
==============================================================================
--- directory/studio/trunk/valueeditors/src/main/java/org/apache/directory/studio/valueeditors/time/InPlaceGeneralizedTimeValueEditor.java
(original)
+++ directory/studio/trunk/valueeditors/src/main/java/org/apache/directory/studio/valueeditors/time/InPlaceGeneralizedTimeValueEditor.java
Mon Aug 18 04:42:23 2008
@@ -23,9 +23,9 @@
 
 import java.text.DateFormat;
 import java.text.ParseException;
-import java.text.SimpleDateFormat;
 import java.util.Date;
 
+import org.apache.directory.shared.ldap.util.GeneralizedTime;
 import org.apache.directory.studio.ldapbrowser.core.model.IValue;
 import org.apache.directory.studio.valueeditors.AbstractInPlaceStringValueEditor;
 
@@ -61,31 +61,17 @@
 
         if ( !showRawValues() )
         {
-            DateFormat ldapFormat = new SimpleDateFormat( "yyyyMMddHHmmssZ" );
-            DateFormat activeDirectoryFormat = new SimpleDateFormat( "yyyyMMddHHmmss'.'SSSZ"
);
             DateFormat targetFormat = DateFormat.getDateTimeInstance( DateFormat.MEDIUM,
DateFormat.LONG );
 
-            String s = displayValue;
-            if ( s.matches( "[\\.0-9]+Z" ) )
-            {
-                s = s.replaceAll( "Z", "GMT" );
-            }
-
             try
             {
-                Date date = ldapFormat.parse( s );
+                GeneralizedTime generalizedTime = new GeneralizedTime( displayValue );
+                Date date = generalizedTime.getCalendar().getTime();
                 displayValue = targetFormat.format( date ) + " (" + displayValue + ")";
             }
-            catch ( ParseException e1 )
+            catch ( ParseException pe )
             {
-                try
-                {
-                    Date date = activeDirectoryFormat.parse( s );
-                    displayValue = targetFormat.format( date ) + " (" + displayValue + ")";
-                }
-                catch ( ParseException e2 )
-                {
-                }
+                // show the raw value in that case
             }
         }
 



Mime
View raw message