Go Premium for a chance to win a PS4. Enter to Win

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 198
  • Last Modified:

how to get the digital clock formating

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
ms_lost
Asked:
ms_lost
  • 2
  • 2
1 Solution
 
bobbit31Commented:
you mean?
DateFormat timeFormat = new SimpleDateFormat("H:mm:ss");
System.out.println(timeFormat.format(Calendar.getInstance.getTime()));
0
 
ms_lostAuthor Commented:
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
 
bobbit31Commented:
sorry, i don't understand what you want... can you possibly show some code?
0
 
ms_lostAuthor Commented:
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
 
yongsingCommented:
System.out.println((hour < 10 ? "0" : "") + hour + ":" +
   (min < 10 ? "0" : "") + min + ":" +
   (seconds < 10 ? "0" : "") + seconds);
0

Featured Post

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

  • 2
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now