Hi Friends, This is shyam Kumar, in a project i need to take the date from the user and convert it to Date format. Can some one Help me in converting a date in String format to java.util.Date format . thank you
Hi Paul Sturrock, thank you for advice, but ive done all that finally come to the fourm. there is a way that we can convert the Date in String format to Date but the String must be in specific format only ie for ex Aug 16, 1981. . What I want is that, I must be able to give date in a any of the String format and able to build a Date object. ( MM/dd/yyyy, yyyy/mm/dd or dd/mm/yyyy or mm/dd/yy).
Parsing a String to a Date where the date can be in any valid Date format is a big task. The API comes with SimpleDateFormat which is (as you can probably gather from the name) a simple extension of the abstract class DateFormat. One SimpleDateFormat object has only one date format, if you follow. What you need is to write your own extension of DateFormat so it can accept an array of formats. Any this is where it gets difficult - how do you actually workout what is a date? You need to define an complete list of formats your program can accept and have your DateFormat class's parse method handle them all.
Joined: Dec 16, 2003
Hi Paul, Thank you for your suggestion, any how iam doing the same thing using three combo boxes. and validating them in the same manner. bye bye have a nice day