I have a problem parsing just the time string from my database
private static final String TIME_FORMAT = "HH:mm:ss";
public static final SimpleDateFormat timeFormat = new SimpleDateFormat(TIME_FORMAT, Locale.getDefault());
And following the output:
String time = "17:17:57";
Date myParsedDate = timeFormat.parse(time); //forget the exception thing
//output of myParsedDate.toString = "Thu Jan 01 16:47:57 GMT+08:00 1970"
It seems as though theres a problem with the locale or something.. just a simple string.. Why is this so? i just want the date to be the having the time i need for my time picker.. gee..
Edit Because i am using a static time format i decided to use my little helper method
public static Date getTimeFromTimeString(String timeString)
{
String[] splitStrings = timeString.split(":");
Date timeDate = new Date();
timeDate.setHours(Integer.parseInt(splitStrings[0]));
timeDate.setMinutes(Integer.parseInt(splitStrings[1]));
timeDate.setSeconds(Integer.parseInt(splitStrings[2]));
return timeDate;
}
Thanks for the help Jon Skeet.. I believe it is the TimeZone offset that is causing this.. .. ill just stick to my little method..