Use DateFormatter classes my friend. Java.util.date may not be supported.. Check if the string that you look for is Correct & recognized by your class methods. String formats are not mostly the problems.
Thanks, jd On 10/4/10, Paul Singleton <[email protected]> wrote: > You can try something like this, you just need to change the value of the > SimpleDateFormat to what you need: > > import java.text.SimpleDateFormat; > import java.util.Calendar; > > public class NewClass { > > public static void main(String args []){ > > Calendar cal = Calendar.getInstance(); > SimpleDateFormat sfd = new SimpleDateFormat("EEE MMM dd hh:mm:ss z > yyyy"); > String s = sfd.format(cal.getTime()); > > System.out.println(s); > } > } > > 2010/10/4 Nguyễn Đình Đoàn <[email protected]> > >> Hi friends, >> >> When I run command: System.out.println(new Date()); >> It printed out: *Tue Oct 05 00:32:53 ICT 2010* >> So, If I have a String as "*Tue Oct 05 00:32:53 ICT 2010"* >> *How to convert it to Date (java.util.Date)* >> * >> * >> I tried running: >> >> * >> DateFormat f = new SimpleDateFormat("EEE MMM dd hh:mm:ss z yyyy"); >> * >> * >> System.out.println("New Date: " + f.parse("Tue Oct 05 00:26:28 ICT >> 2010")); >> >> * >> >> But got error: >> >> *Exception in thread "main" java.text.ParseException: Unparseable date: >> "Tue Oct 05 00:26:28 ICT 2010"* >> * >> * >> >> Thanks ! >> Doan Nguyen Dinh >> >> -- >> To post to this group, send email to >> [email protected] >> To unsubscribe from this group, send email to >> [email protected]<javaprogrammingwithpassion%[email protected]> >> For more options, visit this group at >> http://groups.google.com/group/javaprogrammingwithpassion?hl=en > > -- > To post to this group, send email to > [email protected] > To unsubscribe from this group, send email to > [email protected] > For more options, visit this group at > http://groups.google.com/group/javaprogrammingwithpassion?hl=en -- To post to this group, send email to [email protected] To unsubscribe from this group, send email to [email protected] For more options, visit this group at http://groups.google.com/group/javaprogrammingwithpassion?hl=en
