how to validate time in jsp or java

hi i want to validate time that i have recieved from a html form such that it is numeric and can be in the format of hh.mm or hh:mm or hh-mm. i must not validate it using javascript. so please help me friends. i should validate time on server side using java or jsp.thnx
[291 byte] By [rakesh.pachavaa] at [2007-11-26 19:16:30]
# 1
hi,I think javscricpt is the best way to do that.but you want to do using jsp means something like service side validation.so if your are MVC2 design pattern then use Struts Validation Framework .and another solution is to use JSTL tag <c:fmt> tag.
CookBookJa at 2007-7-9 21:29:37 > top of Java-index,Enterprise & Remote Computing,Web Tier APIs...
# 2
Use the fmt:formatDate and fmt:formatNumber
CookBookJa at 2007-7-9 21:29:37 > top of Java-index,Enterprise & Remote Computing,Web Tier APIs...
# 3
Can you plese guide me how to use the fmt operator for time validation?can you help me by giving some sample code or sothanx CookBookJ
rakesh.pachavaa at 2007-7-9 21:29:37 > top of Java-index,Enterprise & Remote Computing,Web Tier APIs...
# 4

hi,

Include this one in JSP page

<%@ taglib uri="http://java.sun.com/jstl/core" prefix="c" %>

<%@ taglib uri="http://java.sun.com/jstl/fmt" prefix="fmt" %>

I hope you have heared about jstl.

//create an object representing the current date

<jsp:useBean id="now" class="java.util.Date"/>

//create a java class that convert in your format

Try this...

String stringDate = "20/01/1999";

try

{

SimpleDateFormat formatter = new SimpleDateFormat

("dd/MM/yyyy");

ParsePosition pos = new ParsePosition(0);

Date date = formatter.parse(stringDate, pos);

}

catch (Exception e)

{

//Date is not valid

throw new IllegalArgumentException();

}

//output the date

<fmt:formatDate type="both" value="${now}" dateStyle="full" timeStyle="short" />

Regards

CookBookJ

CookBookJa at 2007-7-9 21:29:37 > top of Java-index,Enterprise & Remote Computing,Web Tier APIs...