Solved

how to get the digital clock formating

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

How to improve team productivity

Quip adds documents, spreadsheets, and tasklists to your Slack experience
- Elevate ideas to Quip docs
- Share Quip docs in Slack
- Get notified of changes to your docs
- Available on iOS/Android/Desktop/Web
- Online/Offline

Join & Write a Comment

Suggested Solutions

Title # Comments Views Activity
sumDigits  challenge 7 60
groupSum6 challenge 6 35
topping2 challenge 13 59
eclipse java  build path 6 21
Java had always been an easily readable and understandable language.  Some relatively recent changes in the language seem to be changing this pretty fast, and anyone that had not seen any Java code for the last 5 years will possibly have issues unde…
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 about if statements in Java and their use The if statement: The condition required to create an if statement: Variations of if statements: An example using if statements:
This tutorial covers a step-by-step guide to install VisualVM launcher in eclipse.

757 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

19 Experts available now in Live!

Get 1:1 Help Now