From: <ap...@vh...> - 2006-04-19 21:26:42
|
Author: apevec Date: 2006-04-19 23:24:07 +0200 (Wed, 19 Apr 2006) New Revision: 1112 Modified: trunk/ccm-core/src/com/arsdigita/bebop/parameters/TimeParameter.java Log: avoid 'For input string: ""' validation errors Modified: trunk/ccm-core/src/com/arsdigita/bebop/parameters/TimeParameter.java =================================================================== --- trunk/ccm-core/src/com/arsdigita/bebop/parameters/TimeParameter.java 2006-04-19 11:02:05 UTC (rev 1111) +++ trunk/ccm-core/src/com/arsdigita/bebop/parameters/TimeParameter.java 2006-04-19 21:24:07 UTC (rev 1112) @@ -19,6 +19,8 @@ package com.arsdigita.bebop.parameters; import com.arsdigita.globalization.Globalization; +import com.arsdigita.util.StringUtils; + import java.util.Calendar; import java.util.Date; import java.util.GregorianCalendar; @@ -74,20 +76,26 @@ String minute = Globalization.decodeParameter(request, getName()+".minute"); String second = Globalization.decodeParameter(request, getName()+".second"); String amOrPm = Globalization.decodeParameter(request, getName()+".amOrPm"); + + if (StringUtils.emptyString(hour) && + StringUtils.emptyString(minute) && + StringUtils.emptyString(second)) { + return transformSingleValue(request); + } - if ( hour != null ) { - int hourInt = Integer.parseInt(hour); - if (hourInt == 12) { - hourInt = 0; - } + if (!StringUtils.emptyString(hour)) { + int hourInt = Integer.parseInt(hour); + if (hourInt == 12) { + hourInt = 0; + } c.set(Calendar.HOUR, hourInt); } - if ( minute != null ) { + if (!StringUtils.emptyString(minute)) { c.set(Calendar.MINUTE, Integer.parseInt(minute)); } - if ( second != null ) { + if (!StringUtils.emptyString(second)) { c.set(Calendar.SECOND, Integer.parseInt(second)); } |