1
I came across an exercise in which to convert the date of AM/PM format to military format (24h).
So, suppose the user type 07:05:45PM, the program should return 19:05:45.
I don’t really like looking for solutions on the Internet, but I had no idea how to solve this issue and I came across the following solution:
Console.WriteLine(DateTime.Parse(Console.ReadLine()).ToString("HH:mm:ss"));
Even searching the internet, I could not understand how this method works. Could you explain to me?
This code is more correct than the code in the question, and its answer is the best in code, but unfortunately it offers no explanation. If you can write about - and mainly explain the difference between
h
andH
for the methodParseExact
- will have my vote.– Oralista de Sistemas
@Renan I’m complementing, just a moment
– Rovann Linhalis