Reputation: 2402
I have a string that says 15:00:00
how can I limit the length of the string so it says 15:00
?
Upvotes: 0
Views: 172
Reputation: 1891
For dates
Date date = new Date();
SimpleDateFormat sd = new SimpleDateFormat("HH:mm");
sd.format(date); //will return formatted date
Upvotes: 3
Reputation: 132992
try this:
String time = "15:00:00";
String str =time.substring(0,result.length() - 3);
Upvotes: 0
Reputation: 109257
Try this,
String time = "15:00:00";
time = time.subString(0,time.lastIndexOf(":"));
Upvotes: 3