I am building a form that allows a user to select two dates(input boxes)in which to perform a search on. The users entered criteria will always be formatted to the MM/dd/yyyy format. However, in order for my query to work I need to format the date as follows: yyyy/MM/dd.
Otherwise I get the following exception:
I have googled, search SDN forums and here but I haven't found the solution to my problem.
I have tried the following in my servlet(from examples online):
What I dont understand is the out print lines I am logging which are as follows:
Which API should I be looking at? It seems like I need to use both java.text.SimpleDateFormat and java.text.DateFormat or perhaps one or the other. Why are my print outs so completely off my actual input dates? And is there a way to format a date string from MM/dd/yyyy to date yyyy/MM/dd?
I would appreciate any clarification on the above issues.
Thanks in advance - regards, Crystal Bazil [ December 09, 2005: Message edited by: Crystal Bazil ]
Or you change the pattern by passing in a new format string to the applyPattern() method of the same SDF object.
The thing to remember is that parse() uses the pattern to determine what format the input (the String you are parsing) should be in. On the other hand, format() uses the pattern to determine the format of the output.
Joined: Sep 28, 2004
Junilu - Your solution solved my issue. I appreciate the explanation and you time!
I’ve looked at a lot of different solutions, and in my humble opinion Aspose is the way to go. Here’s the link: http://aspose.com