I am using the SimpleDateFormat to get the time in a format. When I do that I get the format in a String variable. I wonder if there is a built in method to get the hour and the minute from the string variable separatly?
SimpleDateFormat sdf = new SimpleDateFormat("hh:mm a");
String time = sdf.format(calendar.getTime());
Lets say my string get this format: 12:34 AM
I want to separate the hour and the minute. I want 12 and 34 in a new variable.
I don't want to use this:
int hour = calendar.get(Calendar.HOUR_OF_DAY);
Because I only have access to the string variable when I save it in SharedPreferences.