Originally posted by elli dian: ...Please give me a solution again!!
Whoa, calm down buddy. Have you looked at the documentation for the Simple DateFormat that mohit was referring to? Although there may have been a slight syntax error, you were definitely steered in the right direction. [ May 29, 2006: Message edited by: Garrett Rowe ]
Some problems are so complex that you have to be highly intelligent and well informed just to be undecided about them. - Laurence J. Peter
You need to find a list of error messages. Try here. "Cannot be resolved" probably means you haven't imported the SimpleDateFormat.
You need to find which package it is in. Go to the API specification, here, click "FRAMES," then find the name of your class in the lower left frame. To get details click on SomeClass, but if you just let the mouse hover over the name, a box appears with "Class in java.somepackage" in. then writeORRemember the import declarations come one line before the name of the class.
Joined: Mar 22, 2006
here is one more thing that you will have to change if you are trying to convert a string "2006-05-22 14:04:59:612" then the format you will use should be exactly the same "yyyy-MM-dd HH:mm:ss:SSS" other wise you will get a parse exception.
and if you ask for a solution you will get one but i think you want a fully running code which you can just copy paste and run, where as you should refer to the pointers given in this forum and then refer to java api documentation to understand what is actually going on in those functions.
i hope you understand what i have pointed out here.
For anything to String conversion you can just use one of the many String.valueOf methods. These will call Integer.toString, Long.toString etc, but it's easy to have one single entry point.
String to any primitive can be done using the <Wrapper>.parse<type> methods, e.g. Integer.parseInt, but also Double.parseDouble and Boolean.parseBoolean. Character / char is the only exception but that's easy enough: just check for the length and take str.charAt(0).