Solved

how to get the digital clock formating

Posted on 2002-03-19
5
158 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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Unexpected HttpURLConnection connection behavior 2 86
eclipse shortcuts 9 45
replace a word with other 1 40
arguments to jar 5 15
Java Flight Recorder and Java Mission Control together create a complete tool chain to continuously collect low level and detailed runtime information enabling after-the-fact incident analysis. Java Flight Recorder is a profiling and event collectio…
Java functions are among the best things for programmers to work with as Java sites can be very easy to read and prepare. Java especially simplifies many processes in the coding industry as it helps integrate many forms of technology and different d…
Viewers will learn about arithmetic and Boolean expressions in Java and the logical operators used to create Boolean expressions. We will cover the symbols used for arithmetic expressions and define each logical operator and how to use them in Boole…
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:

910 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

Need Help in Real-Time?

Connect with top rated Experts

17 Experts available now in Live!

Get 1:1 Help Now