Solved

how to get the digital clock formating

Posted on 2002-03-19
5
164 Views
Last Modified: 2010-03-31
how to get the digital clock formating
i mean to make the output
00:00:00
10:03:10

something like that
waiting as soon as possible

and can i add the currency of my country infront of the money.. and how to do it

plz plz plz don't be late
0
Comment
Question by:ms_lost
  • 2
  • 2
5 Comments
 
LVL 18

Expert Comment

by:bobbit31
ID: 6881186
you mean?
DateFormat timeFormat = new SimpleDateFormat("H:mm:ss");
System.out.println(timeFormat.format(Calendar.getInstance.getTime()));
0
 

Author Comment

by:ms_lost
ID: 6881247
no i'll allow the user to enter time in seconds and i'll convert it for him.. so is what u've said will help me or what..i did the conversion things..but how to show them in that format

plz don't be late..i want to sleeeeeeeeeeeeeeep
0
 
LVL 18

Expert Comment

by:bobbit31
ID: 6881297
sorry, i don't understand what you want... can you possibly show some code?
0
 

Author Comment

by:ms_lost
ID: 6881311
import cs1.Keyboard;

public class Sec
{
     public static void main (String []args)
     {
     float sec;
     int min;
     int hour;
     int seconds;
     int mod,mod1;
     System.out.println("Enter the duration of time in Seconds please:");
     sec=Keyboard.readFloat();


     hour=(int)(sec/3600);

     mod=(int)(sec%3600);

     min=mod/60;

     mod1=mod%60;

     seconds=mod1;

     System.out.println("the time is :"+hour+":"+min+":"+seconds);


}
}

see the last system.out.. if the out put is only 1:30:5.. iwant it to be 01:30:05 ..is it clear now :))))))))))
0
 
LVL 9

Accepted Solution

by:
yongsing earned 50 total points
ID: 6881583
System.out.println((hour < 10 ? "0" : "") + hour + ":" +
   (min < 10 ? "0" : "") + min + ":" +
   (seconds < 10 ? "0" : "") + seconds);
0

Featured Post

Live: Real-Time Solutions, Start Here

Receive instant 1:1 support from technology experts, using our real-time conversation and whiteboard interface. Your first 5 minutes are always free.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
splitOdd10 challenge 5 104
Java Options in Zimbra Server 2 50
print map entry 34 67
How to convert from xls to xlsx using java 7 36
For customizing the look of your lightweight component and making it look lucid like it was made of glass. Or: how to make your component more Apple-ish ;) This tip assumes your component to be of rectangular shape and completely opaque. (COD…
Basic understanding on "OO- Object Orientation" is needed for designing a logical solution to solve a problem. Basic OOAD is a prerequisite for a coder to ensure that they follow the basic design of OO. This would help developers to understand the b…
Viewers will learn one way to get user input in Java. Introduce the Scanner object: Declare the variable that stores the user input: An example prompting the user for input: Methods you need to invoke in order to properly get  user input:
This video teaches viewers about errors in exception handling.

808 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question