directory-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From pamarce...@apache.org
Subject svn commit: r1493785 - /directory/shared/trunk/util/src/main/java/org/apache/directory/api/util/GeneralizedTime.java
Date Mon, 17 Jun 2013 14:42:33 GMT
Author: pamarcelot
Date: Mon Jun 17 14:42:33 2013
New Revision: 1493785

URL: http://svn.apache.org/r1493785
Log:
Added a method allowing to get the Generalized Time without the fraction information.

Modified:
    directory/shared/trunk/util/src/main/java/org/apache/directory/api/util/GeneralizedTime.java

Modified: directory/shared/trunk/util/src/main/java/org/apache/directory/api/util/GeneralizedTime.java
URL: http://svn.apache.org/viewvc/directory/shared/trunk/util/src/main/java/org/apache/directory/api/util/GeneralizedTime.java?rev=1493785&r1=1493784&r2=1493785&view=diff
==============================================================================
--- directory/shared/trunk/util/src/main/java/org/apache/directory/api/util/GeneralizedTime.java
(original)
+++ directory/shared/trunk/util/src/main/java/org/apache/directory/api/util/GeneralizedTime.java
Mon Jun 17 14:42:33 2013
@@ -627,6 +627,43 @@ public class GeneralizedTime implements 
 
 
     /**
+     * Returns the string representation of this generalized time. 
+     * This method uses the same format as the user provided format.
+     *
+     * @return the string representation of this generalized time
+     */
+    public String toGeneralizedTimeWithoutFraction()
+    {
+        return toGeneralizedTime( getFormatWithoutFraction( upFormat ), upFractionDelimiter,
upFractionLength,
+            upTimeZoneFormat );
+    }
+
+
+    /**
+     * Gets the corresponding format with fraction.
+     *
+     * @param f the format
+     * @return the corresponding format without fraction
+     */
+    private Format getFormatWithoutFraction( Format f )
+    {
+        switch ( f )
+        {
+            case YEAR_MONTH_DAY_HOUR_FRACTION:
+                return Format.YEAR_MONTH_DAY_HOUR;
+            case YEAR_MONTH_DAY_HOUR_MIN_FRACTION:
+                return Format.YEAR_MONTH_DAY_HOUR_MIN;
+            case YEAR_MONTH_DAY_HOUR_MIN_SEC_FRACTION:
+                return Format.YEAR_MONTH_DAY_HOUR_MIN_SEC;
+            default:
+                break;
+        }
+
+        return f;
+    }
+
+
+    /**
      * Returns the string representation of this generalized time.
      * 
      * @param format the target format



Mime
View raw message