Skip to content

Instantly share code, notes, and snippets.

@imedadel
Created October 14, 2019 20:34
Show Gist options
  • Select an option

  • Save imedadel/1d27270824d31ba2c95e59f08f3f9289 to your computer and use it in GitHub Desktop.

Select an option

Save imedadel/1d27270824d31ba2c95e59f08f3f9289 to your computer and use it in GitHub Desktop.
static String timeConversion(String s) {
String t = s.substring(0, 2);
String p = s.substring(s.length() - 2, s.length());
if(p.equals("AM")) {
if(t.equals("12")) t = "00";
} else {
if(!t.equals("12")) t = Integer.toString(Integer.parseInt(t) + 12);
}
return t + s.substring(2, s.length()-2);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment