i got problem to convert String time to Time object because it print together with Date. this is my code.
String time = \"15:30:18\";
DateFormat sdf = ne
Use the same SimpleDateFormat
that you used to parse it:
String time = "15:30:18";
DateFormat sdf = new SimpleDateFormat("hh:mm:ss");
Date date = sdf.parse(time);
System.out.println("Time: " + sdf.format(date));
Remember, the Date
object always represents a combined date/time value. It can't properly represent a date-only or time-only value, so you have to use the correct DateFormat
to ensure you only "see" the parts that you want.