Convert 12 hr time to 24 hr format in java
public static String convertToTwentyFour(String tareekh) { SimpleDateFormat displayFormat = new SimpleDateFormat("HH:mm"); SimpleDateFormat parseFormat = new SimpleDateFormat("hh:mm a"); Date date = null; try { date = parseFormat.parse(tareekh); //System.out.println(parseFormat.format(date) + " = " + displayFormat.format(date)); return displayFormat.format(date); } catch (ParseException e) { e.printStackTrace(); } return null; }
No comments: