directory-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From akaras...@apache.org
Subject svn commit: r392646 - /directory/trunks/shared/ldap/src/main/java/org/apache/directory/shared/ldap/util/DateUtils.java
Date Sun, 09 Apr 2006 00:35:59 GMT
Author: akarasulu
Date: Sat Apr  8 17:35:58 2006
New Revision: 392646

URL: http://svn.apache.org/viewcvs?rev=392646&view=rev
Log:
adding more data utility functionality

Modified:
    directory/trunks/shared/ldap/src/main/java/org/apache/directory/shared/ldap/util/DateUtils.java

Modified: directory/trunks/shared/ldap/src/main/java/org/apache/directory/shared/ldap/util/DateUtils.java
URL: http://svn.apache.org/viewcvs/directory/trunks/shared/ldap/src/main/java/org/apache/directory/shared/ldap/util/DateUtils.java?rev=392646&r1=392645&r2=392646&view=diff
==============================================================================
--- directory/trunks/shared/ldap/src/main/java/org/apache/directory/shared/ldap/util/DateUtils.java
(original)
+++ directory/trunks/shared/ldap/src/main/java/org/apache/directory/shared/ldap/util/DateUtils.java
Sat Apr  8 17:35:58 2006
@@ -18,6 +18,7 @@
 
 
 import java.text.SimpleDateFormat;
+import java.util.Calendar;
 import java.util.Date;
 import java.util.TimeZone;
 
@@ -38,8 +39,57 @@
     {
         dateFormat.setTimeZone( UTC_TIME_ZONE );
     }
+    
+    
+    public static Date getDate( String zuluTime )
+    {
+        Calendar cal = Calendar.getInstance( UTC_TIME_ZONE );
+        cal.set( Calendar.YEAR, getYear( zuluTime ) ); 
+        cal.set( Calendar.MONTH, getMonth( zuluTime ) ); 
+        cal.set( Calendar.DAY_OF_MONTH, getDay( zuluTime ) ); 
+        cal.set( Calendar.HOUR_OF_DAY, getHour( zuluTime ) ); 
+        cal.set( Calendar.MINUTE, getMinutes( zuluTime ) );
+        cal.set( Calendar.SECOND, getSeconds( zuluTime ) );
+        return cal.getTime();
+    }
 
 
+    public static int getYear( String zuluTime )
+    {
+        return Integer.parseInt( zuluTime.substring( 0, 4 ) );
+    }
+    
+    
+    public static int getMonth( String zuluTime )
+    {
+        return Integer.parseInt( zuluTime.substring( 4, 6 ) );
+    }
+    
+    
+    public static int getDay( String zuluTime )
+    {
+        return Integer.parseInt( zuluTime.substring( 6, 8 ) );
+    }
+    
+    
+    public static int getHour( String zuluTime )
+    {
+        return Integer.parseInt( zuluTime.substring( 8, 10 ) );
+    }
+    
+    
+    public static int getMinutes( String zuluTime )
+    {
+        return Integer.parseInt( zuluTime.substring( 10, 12 ) );
+    }
+    
+    
+    public static int getSeconds( String zuluTime )
+    {
+        return Integer.parseInt( zuluTime.substring( 12, 14 ) );
+    }
+    
+    
     /**
      * Gets the generalized time using the "Z" form of the g-time-zone described
      * by [<a href=



Mime
View raw message