You are viewing a single comment's thread. Return to all comments →
public static String timeConversion(String s) { String format = s.substring(8); int hours = Integer.parseInt(s.substring(0,2)); String military = ""; DecimalFormat df = new DecimalFormat("00"); if(format.equals("PM")){ if(hours >= 1 && hours <= 11) hours = hours+12; military = df.format(hours)+s.substring(2,8); } else{ if(hours == 12) hours = 0; military = df.format(hours)+s.substring(2,8); } return military; }
Seems like cookies are disabled on this browser, please enable them to open this website
Time Conversion
You are viewing a single comment's thread. Return to all comments →
Simple Solution in Java 7