0

I have a string that says 15:00:00 how can I limit the length of the string so it says 15:00 ?

2
  • 1
    i think your question is not clear.and refresh it Commented Jun 22, 2012 at 9:33
  • Limit it while taking input from user or limit it for the purpose of application? Commented Jun 22, 2012 at 9:33

3 Answers 3

3

For dates

Date date = new Date(); SimpleDateFormat sd = new SimpleDateFormat("HH:mm"); sd.format(date); //will return formatted date 
Sign up to request clarification or add additional context in comments.

Comments

3

Try this,

String time = "15:00:00"; time = time.subString(0,time.lastIndexOf(":")); 

Comments

0

try this:

String time = "15:00:00"; String str =time.substring(0,result.length() - 3); 

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.