Look at this code, what it will come out?
import java.text.SimpleDateFormat; public class Test{ |
The result is:
247625706-07-03 |
Is this what you expected? You thought it would have thrown an exception of invalid format of text you passed in.
It's very common for a developer do date and time data conversion from text and vice versa in different format. Will it breach your boundary validation if you purely rely on this stupid SimpleDateFormat class?
Work around so far like:
import java.text.SimpleDateFormat; public class Test{ |
Ugly codes, but works.
How many online Web systems relying on Java and J2EE have those codes?
1 comment:
DateFormat.setLenient(false);
Post a Comment