[MOBY-guts] biomoby commit

Martin Senger senger at dev.open-bio.org
Mon May 21 00:56:15 UTC 2007


senger
Sun May 20 20:56:15 EDT 2007
Update of /home/repository/moby/moby-live/Java/src/main/org/biomoby/shared/datatypes
In directory dev.open-bio.org:/tmp/cvs-serv8252/src/main/org/biomoby/shared/datatypes

Modified Files:
	MobyDateTime.java 
Log Message:

moby-live/Java/src/main/org/biomoby/shared/datatypes MobyDateTime.java,1.2,1.3
===================================================================
RCS file: /home/repository/moby/moby-live/Java/src/main/org/biomoby/shared/datatypes/MobyDateTime.java,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- /home/repository/moby/moby-live/Java/src/main/org/biomoby/shared/datatypes/MobyDateTime.java	2006/02/05 12:11:08	1.2
+++ /home/repository/moby/moby-live/Java/src/main/org/biomoby/shared/datatypes/MobyDateTime.java	2007/05/21 00:56:15	1.3
@@ -40,7 +40,7 @@
      * A string defining (in symbols used in Java's SimpleDateFormat)
      * a full Biomoby DateTime format complying with ISO 8601.
      */
-    public static final String FULL_FORMAT = "yyyy-MM-dd'T'HH:mm:ss'Z'Z";
+    public static final String FULL_FORMAT = "yyyy-MM-dd'T'HH:mm:ssZ";
 
     /**
      * An array defining all allowed formats for Biomoby DateTime
@@ -57,7 +57,6 @@
 	"yyyy-MM-dd'T'HH:mm",
 	"yyyy-MM-dd'T'HH:mm:ss",
 	"yyyy-MM-dd'T'HH:mm:ss",
-	"yyyy-MM-dd'T'HH:mm:ss'Z'",
 	FULL_FORMAT
     };
 
@@ -91,25 +90,45 @@
      * Additionally to the same method in the superclass, it checks
      * for a correct format. <p>
      *
+     * It also allows values with the time zone in the format "+hhmm"
+     * and "-hhmm" (instead of correct ones "+hh:mm" and
+     * "-hh:mm"). Such values are the result of SimpleDateFormat
+     * constructor when fed with the {@link #FULL_FORMAT}. <p>
+     *
      * @param value to be stored; if it is null or an empty string it
-     * creates a date/time of the current moment
+     * creates a date/time of the current moment <p>
+     *
      * @throws MobyException if the 'value' does not follow the ISO
      * 8601 specification
      *************************************************************************/
     public void setValue (String value)
 	throws MobyException {
 	GregorianCalendar calendar;
-	if ( value == null || "".equals (value.trim()) ) {
+	if (value == null) {
 	    calendar = MobyDataDateTime.parseISO8601 (null);
 	} else {
-	    // validate
-	    try {
-		calendar = MobyDataDateTime.parseISO8601 (value.trim());
-	    } catch (IllegalArgumentException e) {
-		throw new MobyException (MSG_NOT_VALID_DATE (getName(), value.trim()));
+	    String tValue = value.trim();
+	    if ("".equals (tValue)) {
+		calendar = MobyDataDateTime.parseISO8601 (null);
+	    } else {
+		// validate
+		try {
+		    int len = tValue.length();
+		    if (len > 5 &&
+			( tValue.charAt (len - 5) == '+' ||
+			  tValue.charAt (len - 5) == '-' )) {
+			tValue =
+			    tValue.substring (0, len - 2) +
+			    ':' +
+			    tValue.substring (len - 2);
+		    }
+		    calendar = MobyDataDateTime.parseISO8601 (tValue);
+		} catch (IllegalArgumentException e) {
+		    throw new MobyException (MSG_NOT_VALID_DATE (getName(), tValue));
+		}
 	    }
 	}
-	super.setValue (MobyDataDateTime.getString (calendar));
+ 	super.setValue (MobyDataDateTime.getString (calendar));
     }
 
 }




More information about the MOBY-guts mailing list