I have a string like "hh:mm:ss.SSSSSS"
and I want to convert this string to Date
and I want to get "hh:mm:ss.SS"
. However, when I compile my code, it still gives the day month year time and timezone like "Thu Jan 01 10:50:55 TRT 1970"
. I attached my code below to the text.
String a = "20:50:45.268743";
Date hour;
try {
hour = new SimpleDateFormat("hh:mm:ss.SS").parse(a);
System.out.println(hour);
} catch(ParseException e) {
e.printStackTrace();
}
My output is hu Jan 01 20:55:13 TRT 1970 but I want to get 20:55:45.26.
Is there anyone who can help me about this situation?