import javax.servlet.http.HttpServletRequest;
+import org.cacert.gigi.GigiApiException;
import org.cacert.gigi.localisation.Language;
public class DateSelector implements Outputable {
out.print("\" size=\"4\" autocomplete=\"off\">");
}
- public void update(HttpServletRequest r) {
- String dayS = r.getParameter(names[0]);
- if (dayS != null) {
- day = parseIntSafe(dayS);
- }
-
- String monthS = r.getParameter(names[1]);
- if (monthS != null) {
- month = parseIntSafe(monthS);
- }
+ public void update(HttpServletRequest r) throws GigiApiException {
+ try {
+ String dayS = r.getParameter(names[0]);
+ if (dayS != null) {
+ day = Integer.parseInt(dayS);
+ }
- String yearS = r.getParameter(names[2]);
- if (yearS != null) {
- year = parseIntSafe(yearS);
- }
- }
+ String monthS = r.getParameter(names[1]);
+ if (monthS != null) {
+ month = Integer.parseInt(monthS);
+ }
- private int parseIntSafe(String dayS) {
- try {
- return Integer.parseInt(dayS);
+ String yearS = r.getParameter(names[2]);
+ if (yearS != null) {
+ year = Integer.parseInt(yearS);
+ }
} catch (NumberFormatException e) {
-
+ throw new GigiApiException("Unparsable date.");
}
- return 0;
}
public boolean isValid() {