Home Discussion Discuss: Convert Time to Seconds

• ### my sampleJulius Caesar G. Leonardo January 6, 2012 at 7:31 PM

//second to Hour to minute to second // W/ s or w/out S import java.util.*; import java.io.*; import static java.lang.System.out; class sec { public static void main (String[] args)throws IOException { Runner(); } public static void Runner()throws IOException { Scanner scan = new Scanner(System.in); out.println("Enter Second"); int secsIn = scan.nextInt(); if(secsIn==0) { System.exit(0); }else{ int h = secsIn/3600; int remainder = secsIn % 3600; int minutes = remainder / 60; int seconds = remainder % 60; if(h<=1 && minutes<=1 && seconds<=1) { System.out.println(h+"hour:" + minutes+"minute:" +seconds+"Second"); }else if(h<=1 && minutes<=1 && seconds>=2) { System.out.println(h+"hour:" + minutes+"minute:" +seconds+"Seconds"); }else if(h<=1 && minutes>=2 && seconds<=1) { System.out.println(h+"hour:" + minutes+"minutes:" +seconds+"Second"); }else if(h<=1 && minutes>=2 && seconds>=2) { System.out.println(h+"hour:" + minutes+"minutes:" +seconds+"Seconds"); } else if(h>=2 && minutes<=1 && seconds<=1) { System.out.println(h+"hours:" + minutes+"minute:" +seconds+"Second"); }else if(h>=2 && minutes<=1 && seconds>=2) { System.out.println(h+"hours:" + minutes+"minute:" +seconds+"Seconds"); }else if(h>=2 && minutes>=2 && seconds<=1) { System.out.println(h+"hours:" + minutes+"minutes:" +seconds+"Second"); }else if(h>=2 && minutes>=2 && seconds>=2) { System.out.println(h+" hours " + minutes+" minutes " +seconds+" Seconds "); } Runner(); }}}

Your Name (*) :
Subject (*):

Related Articles
JavaScript Questions

javascript add seconds to time.
javascript add seconds to time.  <html> <head> <title>Add seconds to current times</title> <script type="text/javascript... will not exceed to 59.If it is more than 59 then convert seconds into minutes and add

JavaScript Questions

javascript add seconds to time.
javascript add seconds to time.  I want to add seconds to time. How can I do this?   <html> <head> <title>Add seconds... will not exceed to 59.If it is more than 59 then convert seconds into minutes and add

Java Tips and Examples

Convert Time to Seconds
Convert Time to Seconds       In this section, you will learn to convert Time to seconds. An hour has...: This example helps you in converting a Time to seconds. Here, first of all we have

PHP Questions

maximum execution time of 30 seconds exceeded in php
maximum execution time of 30 seconds exceeded in php  My PHP program is taking long time to run it is giving following error: Maximum execution time of 30 seconds exceeded in php file How to resolve this issue? Thanks

Java Code Examples

Java add seconds to Date
used in date time manipulation. Here, we are going to add few seconds...("Time after 56 seconds: " + sdf.format(addSeconds)); } } Output: Current...Java add seconds to Date In this tutorial, you will learn how to add seconds

Java Tips and Examples

Convert Time to Milliseconds
Convert Time to Milliseconds       In this section, you will learn to convert Time... and seconds to milliseconds as shown below. We also want that the Time would

PHP Tutorial

time ()
PHP time() Function The time() returns the current time  measured in the number of seconds since the Unix Epoch (January 1 1970 00:00:00 GMT...;). Syntax of time() Function in PHP time(void) Parameter of time() Function

C Tutorials

C Current Time
example, the time() function determines the current time in seconds and assigns it to time_t type variable t. The ctime() function converts the number of seconds... C Current Time

PHP Tutorial

PHP Date and Time Date and time Tutorial
;  print(date("Current time is: H (hours), i (minutes), s (seconds... (minutes), 13 (seconds) mktime - get timestamp for date and time value... of seconds between the Unix Epoch (January 1 1970) and the time specified

HTML Questions

calculate the time ..
calculate the time ..  [CODE] Elapsed Time Example...() { startTime = new Date(); alert("Time Started...(); alert("Time Stopped"); } function calculateTimeElapsed

JavaScript Questions

javascript time with am pm
javascript time with am pm  How can I display current time with AM or PM using javascript?   <html> <head> <title>Time... seconds=todayDate.getSeconds(); var format ="AM"; if(hours>11) {format="PM

JavaScript Questions

javascript current date and time.
javascript current date and time.  How can we display current date and time using javascript?   <html> <head> <title>...(); var minutes=todayDate.getMinutes(); var seconds=todayDate.getSeconds

JavaScript Questions

javascript add minutes to time.
; } document.write("Time : " + newHrs + " : " + min + " : " + seconds...javascript add minutes to time.  I want to add minutes to time. How... newHrs = parseInt(hours) + parseInt(hrs); var seconds

JavaScript Questions

javascript add hour to time
javascript add hour to time  I want to add numbers of hours to time... = todayDate.getMinutes(); var seconds = todayDate.getSeconds...; } document.write("Time : " + newHrs + " : " + minutes

Java Interview Questions

how to print of hours and minutes of 8725 seconds
how to print of hours and minutes of 8725 seconds  how to print of hours and minutes of 8725 seconds

Java Interview Questions

how many hours and minutes in 8725 seconds
how many hours and minutes in 8725 seconds  how many hours and minutes in 8725 seconds? Thanks

JSP Interview Questions

JSp session time out
the maximum time in seconds before a session becomes invalid. Its syntax...JSp session time out  Consider a case where we are working on a java...-app> Here time is expressed in minutes.  I got ur point

General

Java get Elapsed Time
Java get Elapsed Time       In this section, you will study how to obtain the elapsed time. As you all know that the Elapsed time is the time taken to complete the process

MySQL

Mysql Time Function
sec) Query to converts the seconds to a time using SEC_TO_TIME(seconds): The Query will help you to return the time by converting the seconds using SEC... Mysql Time Function

Mobile Applications Questions

splash screen time delay iphone
splash screen time delay iphone  How can i delay the splash screen... it's disappears within seconds.. To delay it " NSThread " can be used. Syntax.... For example, display default.png for 5 seconds. - (void

Swing AWT

Date and Time - Swing AWT
between them,,, in terms of years, months, days, hours, minutes and seconds and plz enclose an anther program that does the same for the time.... i tried... that lasts for at least 5 seconds for the actual JFrame is displayed.

General

Set delay time in JOptionPane
the user to enter time in seconds and the message to display. After that using... Set delay time in JOptionPane       In this section, you will learn how to set the time after which

PHP Questions

How to convert date to time in PHP?
How to convert date to time in PHP?  Hi, programmer. The PHP... and time. The PHP "time()" function is used to get the current Unix timestamp, a number representing the number of seconds since January 1, 1970 Greenwich Mean

Java Beginners

how to convert time in milliseconds in to hours - Java Beginners
how to convert time in milliseconds in to hours  hello, can anyone tell me how i can convert the time in milliseconds into hours or to display it in seconds in java

Java Beginners

how to convert time in milliseconds in to hours - Java Beginners
how to convert time in milliseconds in to hours  hello, can anyone tell me how i can convert the time in milliseconds into hours or to display it in seconds in java

Java Beginners

time
time  how to find the current system time between the user login and logout using java

JSP Servlet Questions

time
time  Hi. I have retrieved time from mysql database. its in th format hh:mm:ss. but i want to display only as hh:mm. wat to do? For this i already received the answer. But its converting the time in 24hr format to 12hr format

JSP Servlet Questions

time
time  Hi. I have retrieved time from mysql database. its in th format hh:mm:ss. but i want to display only as hh:mm. wat to do? For this i already received the answer. But its converting the time in 24hr format to 12hr format

JSP Servlet Questions

time
time  Hi. I have retrieved time from mysql database. its in th format hh:mm:ss. but i want to display only as hh:mm. wat to do? For this i already received the answer. But its converting the time in 24hr format to 12hr format

JSP Servlet Questions

time
time  Hi. I have retrieved time from mysql database. its in th format hh:mm:ss. but i want to display only as hh:mm. wat to do? For this i already received the answer. But its converting the time in 24hr format to 12hr format

Tutorial Topics
Questions by Category