Skip to content

Commit

Permalink
pm
Browse files Browse the repository at this point in the history
  • Loading branch information
Nivedita967 committed Jan 4, 2021
1 parent bb30fa9 commit 3b647a0
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions Algorithms/Warmup/Time Conversion/solution.java
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,9 @@ public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
String time = sc.next();
int hour = Integer.parseInt(time.substring(0,2))%12; // getting hours
if(time.contains("PM")) // if time contains "pm"
if(time.contains("PM")) // if time contains "PM"
hour += 12;
// printing time in 24 hour format
System.out.print("%02d%s",hour,time.substring(2,8));
}
}
}

0 comments on commit 3b647a0

Please sign in to comment.