Re: Converting Military Time
Might want to take a look at the DecimalFormat class.
Or the DateFormat class for that matter!
Re: Converting Military Time
I did, but we never went over any of those classes and I'm trying to figure it out with the tools we learned so far. (this is a first semester Java course).
--- Update ---
Ok, I got it to work using this:
Code :
String min1 = String.valueOf(min);
min1 = "0" + min1;
String ordTime = hour + ":" + min1 + " " + period;
return ordTime;
Although we never learned the valueOf class I assume it's ok to use. Not sure what else the teacher would have us do.
Re: Converting Military Time
Re: Converting Military Time
Quote:
Originally Posted by
greystreet34
Ok, I got it to work using this:
Code :
String min1 = String.valueOf(min);
min1 = "0" + min1;
String ordTime = hour + ":" + min1 + " " + period;
return ordTime;
Although we never learned the valueOf class I assume it's ok to use.
valueOf is not a class, it is a method of the String class. You should invest the time it takes to read every word in the documentation on the string class ... )dramatic pause( ... ten times!
Quote:
Originally Posted by
greystreet34
Not sure what else the teacher would have us do.
Me neither. But some good suggestions were made. Did you search for information on DecimalFormat or DateFormat?
Re: Converting Military Time
Thanks for the help everyone, and for the information about cross posting. I wasn't sure about the rules for that and if I do continue to post on different forums I'll be sure to link the other discussions in.
I did look up information about DecimalFormat and DateFormat, but a lot of it seemed over my head for the time being!
Re: Converting Military Time
Quote:
Hi, I'm working on an assignment
Quote:
I did look up information about DecimalFormat and DateFormat, but a lot of it seemed over my head for the time being!
It looks like this may have been the point of the assignment. Just a thought...