You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@directory.apache.org by pa...@apache.org on 2013/06/17 16:42:33 UTC
svn commit: r1493785 -
/directory/shared/trunk/util/src/main/java/org/apache/directory/api/util/GeneralizedTime.java
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