You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@mina.apache.org by Hieu Phan Thanh <hi...@Cybersoft-VN.com> on 2006/12/21 12:22:41 UTC

[mina] Java Time validation

Hello all,

Firstly, I am so sorry for the question not related to MINA framework.

How could I check whether the input String is valid or invalid date time
format?
The application supports user input: yyyyMMddHHmmss
And I use the SimpleDateFormat to parse the inputted String.
If 20061112120000 => expected result: 2006/11/12 12:00:00
If 20061312120000 => expected result: INVALID (however the
SimpleDateFormat parses correctly: 2007/01/12 12:00:00)

I think that it's very stupid if I check each part (yyyy, MM, dd...)
Is there any one know the better way to check this case?
Any help is highly appreciate.

Thanks & best regards,
Hieu Phan.


Re: [mina] Java Time validation

Posted by Jeroen Brattinga <je...@gmail.com>.
You could do a check afterwards on the parsed Date (using the .format
method) to see if the resulting date-string is equal to the original one.

-- 
Jeroen Brattinga


2006/12/21, Hieu Phan Thanh <hi...@cybersoft-vn.com>:
>
> Hello all,
>
> Firstly, I am so sorry for the question not related to MINA framework.
>
> How could I check whether the input String is valid or invalid date time
> format?
> The application supports user input: yyyyMMddHHmmss
> And I use the SimpleDateFormat to parse the inputted String.
> If 20061112120000 => expected result: 2006/11/12 12:00:00
> If 20061312120000 => expected result: INVALID (however the
> SimpleDateFormat parses correctly: 2007/01/12 12:00:00)
>
> I think that it's very stupid if I check each part (yyyy, MM, dd...)
> Is there any one know the better way to check this case?
> Any help is highly appreciate.
>
> Thanks & best regards,
> Hieu Phan.
>
>