How to convert 'dd/mm/yyyy hh:mm:ss am/pm' to hh:mm:ss (without am or pm) in java?

33,416

Solution 1

SimpleDateFormat format = new SimpleDateFormat("dd/MM/yyyy hh:mm:ss a", Locale.US);
Date date = format.parse("1/15/2014 9:57:03 AM");
format = new SimpleDateFormat("HH:mm:ss");
String dateString = format.format(date);

BTW, use Google next time

Solution 2

You should see this in the doc doc SimpleDateFormat

Share:
33,416

Related videos on Youtube

user3205610
Author by

user3205610

Updated on July 05, 2022

Comments

  • user3205610
    user3205610 almost 2 years

    I want the convert the string like 1/15/2014 9:57:03 AM or 1/15/2014 5:49:39 PM to 9:57:03 and 17:49:39