Say GMT time is given to us and we want to convert the time zone offset as input and convert to real time.
The problem is as easy as it can be, but I am stuck on parsing the input. this is from a first chapters of daniel liang’s java book, thus it doesn’t allow us to use anything like if,else, for, while loops etc. I believe this structure is set up so that learners don’t miss the fundamentals.
I need to take +5:30 as input and add it to my current time.
My current time is stored as:
currentHour, currentMinute, currentSecond.
I want to parse + and know it means “add”, parse 5 and know it means 5 hour, and parse 30 and know it means 30 minute and thus find the current real time in my time zone.
AFAIK it’s allowed to use the java libraries but not any if, else, for loops or recursion or anything.
Here’s the expected I/O.
Enter the time zone offset to GMT: -5
The current time is 4:50:34