Solved

how to get the digital clock formating

Posted on 2002-03-19
5
189 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

This was posted to the Netbeans forum a Feb, 2010 and I also sent it to Verisign. Who didn't help much in my struggles to get my application signed. ------------------------- Start The idea here is to target your cell phones with the correct…
In this post we will learn how to connect and configure Android Device (Smartphone etc.) with Android Studio. After that we will run a simple Hello World Program.
This tutorial will introduce the viewer to VisualVM for the Java platform application. This video explains an example program and covers the Overview, Monitor, and Heap Dump tabs.
Viewers will learn how to properly install Eclipse with the necessary JDK, and will take a look at an introductory Java program. Download Eclipse installation zip file: Extract files from zip file: Download and install JDK 8: Open Eclipse and …

622 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