You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@directory.apache.org by se...@apache.org on 2008/08/18 13:42:24 UTC
svn commit: r686730 -
/directory/studio/trunk/valueeditors/src/main/java/org/apache/directory/studio/valueeditors/time/InPlaceGeneralizedTimeValueEditor.java
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
}
}