Date parsing problem
I am getting parse exception while I am trying to format the follwing date " 02:09:07 Jan 26, 2002 PST " using java.text.DateFormat and SimpleFormat class.
I want convert this string to Java.util.Date object. How do I convert that as Date object.
If there is still some option in either of the above classes please tell me in detail( Sample code might help).
Thanks in Advance
V Sivakumar
hmm, can't be first post anymore :(
anyhow, i tryed to create some code and here's what i came up withimport java.text.SimpleDateFormat;
import java.util.Date;
public class SDF {
public static void main(String[] args) throws Exception {
SimpleDateFormat sdf = new SimpleDateFormat("HH:mm:ss MMM d, yyyy z");
System.out.println(sdf.format(new Date()));
System.out.println(sdf.parse(args[0],
new java.text.ParsePosition(0)));
}
}
you just compile it javac SDF.java and run it java SDF "09:09:23 Jaan 12, 2002 EET" (or whatever argument works for you)
anyhow, it prints out current date, so you can see how it formats date according to that format string....
i notieced that in my countri this MMM is shown as Jaan, Veebr, ... so, that's why i got null most of times while i tryed to use string that you had...
oh, and that java.text.ParsePosition was necessary as well...