You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@myfaces.apache.org by ma...@apache.org on 2005/12/19 20:23:56 UTC

svn commit: r357759 - in /myfaces/tomahawk/trunk/src/java/org/apache/myfaces/custom/date: HtmlDateRenderer.java HtmlInputDate.java

Author: matzew
Date: Mon Dec 19 11:23:49 2005
New Revision: 357759

URL: http://svn.apache.org/viewcvs?rev=357759&view=rev
Log:
fast shot... no it looks better ;)

Modified:
    myfaces/tomahawk/trunk/src/java/org/apache/myfaces/custom/date/HtmlDateRenderer.java
    myfaces/tomahawk/trunk/src/java/org/apache/myfaces/custom/date/HtmlInputDate.java

Modified: myfaces/tomahawk/trunk/src/java/org/apache/myfaces/custom/date/HtmlDateRenderer.java
URL: http://svn.apache.org/viewcvs/myfaces/tomahawk/trunk/src/java/org/apache/myfaces/custom/date/HtmlDateRenderer.java?rev=357759&r1=357758&r2=357759&view=diff
==============================================================================
--- myfaces/tomahawk/trunk/src/java/org/apache/myfaces/custom/date/HtmlDateRenderer.java (original)
+++ myfaces/tomahawk/trunk/src/java/org/apache/myfaces/custom/date/HtmlDateRenderer.java Mon Dec 19 11:23:49 2005
@@ -17,6 +17,7 @@
 
 import java.io.IOException;
 import java.text.DateFormatSymbols;
+import java.text.ParseException;
 import java.util.Calendar;
 import java.util.Locale;
 import java.util.Map;
@@ -322,7 +323,7 @@
         UserData userData = (UserData) submittedValue;
         try {
             return userData.parse();
-        } catch (NumberFormatException e) {
+        } catch (ParseException e) {
             Object[] args = {uiComponent.getId()};
             throw new ConverterException(MessageUtils.getMessage(FacesMessage.SEVERITY_ERROR, DATE_MESSAGE_ID, args));
         }

Modified: myfaces/tomahawk/trunk/src/java/org/apache/myfaces/custom/date/HtmlInputDate.java
URL: http://svn.apache.org/viewcvs/myfaces/tomahawk/trunk/src/java/org/apache/myfaces/custom/date/HtmlInputDate.java?rev=357759&r1=357758&r2=357759&view=diff
==============================================================================
--- myfaces/tomahawk/trunk/src/java/org/apache/myfaces/custom/date/HtmlInputDate.java (original)
+++ myfaces/tomahawk/trunk/src/java/org/apache/myfaces/custom/date/HtmlInputDate.java Mon Dec 19 11:23:49 2005
@@ -16,6 +16,7 @@
 package org.apache.myfaces.custom.date;
 
 import java.io.Serializable;
+import java.text.ParseException;
 import java.util.Calendar;
 import java.util.Date;
 import java.util.Locale;
@@ -214,29 +215,31 @@
             seconds = Integer.toString(calendar.get(Calendar.SECOND));
         }
 
-        public Date parse() throws NumberFormatException {
+        public Date parse() throws ParseException{
             Calendar tempCalendar=Calendar.getInstance();
             if (timeZone != null)
                    tempCalendar.setTimeZone(timeZone);
-            
-            tempCalendar.set(Calendar.DAY_OF_MONTH,Integer.parseInt(day));
-            tempCalendar.set(Calendar.MONTH,Integer.parseInt(month)-1);
-            tempCalendar.set(Calendar.YEAR,Integer.parseInt(year));
-            if (uses_ampm) {
-            	int int_hours = Integer.parseInt(hours);
-            	// ampm hours must be in range 0-11 to be handled right; we have to handle "12" specially
-            	if (int_hours == 12) {
-        			int_hours = 0;
-            	}
-            	tempCalendar.set(Calendar.HOUR,int_hours);
-                tempCalendar.set(Calendar.AM_PM,Integer.parseInt(ampm));
-            } else {
-            	tempCalendar.set(Calendar.HOUR_OF_DAY,Integer.parseInt(hours));
-            }
-            tempCalendar.set(Calendar.MINUTE,Integer.parseInt(minutes));
-            tempCalendar.set(Calendar.SECOND,Integer.parseInt(seconds));
-            tempCalendar.set(Calendar.MILLISECOND, 0);
-            
+            try{
+	            tempCalendar.set(Calendar.DAY_OF_MONTH,Integer.parseInt(day));
+	            tempCalendar.set(Calendar.MONTH,Integer.parseInt(month)-1);
+	            tempCalendar.set(Calendar.YEAR,Integer.parseInt(year));
+	            if (uses_ampm) {
+	            	int int_hours = Integer.parseInt(hours);
+	            	// ampm hours must be in range 0-11 to be handled right; we have to handle "12" specially
+	            	if (int_hours == 12) {
+	        			int_hours = 0;
+	            	}
+	            	tempCalendar.set(Calendar.HOUR,int_hours);
+	                tempCalendar.set(Calendar.AM_PM,Integer.parseInt(ampm));
+	            } else {
+	            	tempCalendar.set(Calendar.HOUR_OF_DAY,Integer.parseInt(hours));
+	            }
+	            tempCalendar.set(Calendar.MINUTE,Integer.parseInt(minutes));
+	            tempCalendar.set(Calendar.SECOND,Integer.parseInt(seconds));
+	            tempCalendar.set(Calendar.MILLISECOND, 0);
+            } catch (NumberFormatException e) {
+            	throw new ParseException(e.getMessage(),0);
+            } 
             return tempCalendar.getTime();
         }