Latest Tutorials| Questions and Answers|Ask Questions?|Site Map



Home Answers Viewqa Swing-AWT converstion from minutes to days format

Have Programming Question? Ask it here!
 
 
 


raveen
converstion from minutes to days format
1 Answer(s)      2 years and 9 months ago
Posted in : Swing AWT


i have one text field ,in that it taking time in seconds for example 1560 seconds,but i need in the format like example: 09days:10 hrs:10 mins. i need code for change this

thankls in advance


Advertisement
View Answers

October 13, 2011 at 5:09 PM


import java.util.*;
import java.text.*;
import javax.swing.*;
import java.awt.event.*;
class ConvertSeconds{
    public static void main(String[] args) 
    {
        JFrame f=new JFrame();
        JLabel lab=new JLabel("Enter seconds: ");
        final JTextField text=new JTextField(20);
        JButton b=new JButton("Convert");
        b.addActionListener(new ActionListener(){
            public void actionPerformed(ActionEvent e){
                int hr, mn,sec,day;
                long s = Long.parseLong(text.getText());
                day=(int)s/86400;
                hr = (int)(s/3600);
                int rem = (int)(s%3600);
                mn = rem/60;
                sec = rem%60;
                String hrStr = (hr<10 ? "0" : "")+hr;
                String mnStr = (mn<10 ? "0" : "")+mn;
                String secStr = (sec<10 ? "0" : "")+sec; 
                JOptionPane.showMessageDialog(null,day+" days, "+hrStr+ "hrs, "+mnStr+ "minutes "+secStr+" seconds.");

            }
        });
        f.setLayout(null);
        lab.setBounds(10,10,100,20);
        text.setBounds(120,10,100,20);
        b.setBounds(120,40,100,20);
        f.add(lab);
        f.add(text);
        f.add(b);
        f.setVisible(true);
        f.setSize(300,100);
    }
}


Related Tutorials/Questions & Answers:
converstion from minutes to days format
converstion from minutes to days format  i have one text field ,in that it taking time in seconds for example 1560 seconds,but i need in the format like example: 09days:10 hrs:10 mins. i need code for change this thankls
Change Week Days Format
Change Week Days Format       This Example shows you how to change week days format. In the code given below we are change week days format. Methods used
Advertisements
Week Days Format Example
Week Days Format Example       This example shows how to format week days using Format class. In this program we use a pattern of special characters to format week day
Minutes Format Example
Minutes Format Example       This example shows how to format minute using Format class. In this program we use a pattern of special characters to time format. Description
Java subtract days from date
Java subtract days from date In this tutorial, you will learn how to subtract days from date. Using the Calendar class, you can add and subtract date...(-). This will reduce date from date. Here, we are going to subtract few days from
voice to text converstion
voice to text converstion  how i can make a speech to text converstion program in java??? i have no idea about this project. so pls pls help me . thank you>>
voice to text converstion
voice to text converstion  how i can make a speech to text converstion program in java??? i have no idea about this project. so pls pls help me . thank you>>
voice to text converstion
voice to text converstion  how i can make a speech to text converstion program in java??? i have no idea about this project. so pls pls help me . thank you>>
javascript add minutes to time.
+ " " + format); } </script> </head> <body> <h2>Add minutes...javascript add minutes to time.  I want to add minutes to time. How...;title>Add minutes to current times</title> <script type="text/javascript
date_parse_from_format
  date_parse_from_format date_parse_from_format function returns... about given date. Description on PHP Date Parse Format array date_parse_from...:00"; print_r(date_parse_from_format("j.n.Y H:iP", $date
online Converstion - WebSevices
online Converstion  How can I Convert my Image Files to Text Files?  Just click http://www.onlinedocumentconversion.com/, convert your image to doc, rtf or txt format and edit
how to format date from yyyy-mm-dd to dd-mm-yyyy
how to format date from yyyy-mm-dd to dd-mm-yyyy  <!DOCTYPE html... to calculate the nos. of days between two dates, the date format is in "yyyy-mm-dd", so... diff = Math.abs(d1 - d2) document.getElementById("days").value=Math.round(diff
PHP date_create_from_format function
date_create_from_format  function The date_create_from_format... DateTime object formatted according to the specified format.  Description public static DateTime DateTime::createFromFormat ( string $format, string $time
how to upload a file of apk format in a folder from servlet
how to upload a file of apk format in a folder from servlet  How to upload a file of apk format to a folder from servlet, i am trying to do, its getting uploaded as .zip file and not apk file
Java add minutes to Date
Java add minutes to Date In this tutorial, you will learn how to add minutes... used in date time manipulation. Here, we are going to add few minutes... add() of Calendar class, we have added 56 minutes to the calendar which
dynamic retrivel of data from mysql database in table format at jsp
dynamic retrivel of data from mysql database in table format at jsp  ... the data from database and display it as table format in jsp... For example, i have...... At jsp, if i choose A1 from the dropdown list then the corresponding details
Mysql Date Minus Days
an example from Mysql Date Minus Days. To understand the example, we use the select... Mysql Date Minus Days       The Tutorial cover on Mysql Date Minus Days return you the day after
Mysql Date Add Days
:-Date From which you want to add days. INTERVAL expr unit:- Number of the days... Mysql Date Add Days       The Tutorial illustrate an example to add days to the particular
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
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
Mysql Date Last 30 Days
Mysql Date Last 30 Days       Mysql is used to find out the last 30 days from current date. Understand with Example The Tutorial illustrate an example from 'Mysql Date Last 30
DateInterval::format
DateInterval class in PHP DateInterval::format function is used for formatting the interval. It returns the format interval.  Description on PHP DateInterval Format public string DateInterval::format ( string $format
javascript date difference in days.
javascript date difference in days.   I want to find the difference between two dates in terms of days. I am using javascript. Please help.  ... Date() it shows the current date in standard format with current day
10 Minutes Guide to Ant
10 Minutes Guide to Ant       Introduction Well for the next 10 minutes get ready to devote... (with tomcat) downloaded from http://www.apache.org to deploy and test J2EE
How to calculate days in a year
How to calculate days in a year  Hi, How to calculate no of days in a year? I want a program that calculates no of days in a year by specifying year... of calculating days in a year? Thanks
Annotations are using now a days?
Annotations are using now a days?  i have a doubt in Annatation, if we use Annatation we must hardcoding the code/data but sunmicrosystem itself says that hardcoding is not recommended
writing document (.doc) file from java with format such as font type, font style
writing document (.doc) file from java with format such as font type, font style  Can anyone help me how can i write a java code to write a string with format such as font type and style to a document file? Thanks in advance
how to get date format in string from date object containing real date in java
how to get date format in string from date object containing real date in java  i want to get data string format from date object where date object containing real date. date frequently vary in from of only month & year
how to get date format in string from date object containing real date in java
how to get date format in string from date object containing real date in java  i want to get data string format from date object where date object containing real date. date frequently vary in from of only month & year
Programming: Weeks and Days
Java NotesProgramming: Weeks and Days Name _______________________________ Write a program to read in a number of days. It should then display the number of weeks and days that that represents. You can solve this using integer
How to download files from server to local disk using ZIP format in JSP page - JSP-Servlet
How to download files from server to local disk using ZIP format in JSP page  hi i have an application to upload and download multiple files. As i... disk creting ZIP format for all files .how can create ZIp for all files pls help me
Sql Date and Time Format
Sql Date and Time Format       The Tutorial illustrate an example from the 'Sql Date and Time Format'. To understand this example we use the following syntax that 
days between two given dates using PHP
days between two given dates using PHP  How can we know the number of days between two given dates using PHP?   Hi friends, Example: <html> <head> <title>Number of days between two
Date Difference
: 247680 minutes. Time in hours: 4128 hours. Time in days: 172 days... to convert milliseconds into seconds, seconds into minutes, minutes into hours, hours into days. Here we are using Calendar, an abstract base class that extends
image format
image format  what are the different format available in image
image format
image format  what are the different format available in image
Determining the Number of Days in a Month
Determining the Number of Days in a Month   This section will show the way of counting the number of days of a month in the specified year. Following program takes the year as input through the keyboard and shows the number of days
Learn Java in 21 days
Anyone can learn Java in 21 days, all they need is dedication and concentration. Java Guide at RoseIndia can help you learn Java in 21 days. The course... program by watching a Java expert create it. In order to learn Java in 21 days
PHP Date add days
In this example we will create sample code to add days or weeks...;days: ".date('l dS \o\f F Y', $date)."... 2009 Date After adding 30 days: Wednesday 23rd of September 2009  
Mysql Date Format codes
Mysql Date Format codes       The Tutorial illustrate an example from 'Mysql date format... and year.  The syntax (now( ),'%e-%m-%y')  return you the date format
Simple Date Format Exception
Simple Date Format Exception       Simple Date Format Exception inherits from a package name... and normalization of date. Simple Date-format provides you to work on choosing any
in an application one task has to done for every 15 minutes ? How con you do it?
in an application one task has to done for every 15 minutes ? How con you do it?  in an application one task has to done for every 15 minutes ? How con you do
time format
time format  How to seperate time from following DateFormat dateFormat = new SimpleDateFormat("yyyy-dd-mm HH:mm:ss.S
Java get number of Days in Month
Java get number of Days in Month   ... of days in the specified month. This example sets the year as 2008, month.... Here we are going to get the number of days in the month February. Here
Hi..How to Display Days by month - Java Beginners
Hi..How to Display Days by month  Hi Friend.... I have a doubt on date Program... How to display the Number of days..it should display... 30 2008 12 12 --------------------- OUTPUT: 2007 Jan 31 Days 2007
select date in desired format
select date in desired format  how to select date from the database in DD/MM/YYYY format, because if i am trying select data from the database i am getting value in yyyy/mm/dd and time format like below "2012-05-07 00:00:00.0
PHP convert week number to days or month - PHP
PHP convert week number to days or month  Small, simple and easy code that can do following task: 1.Convert Week Numbers to Month 2.Convert Week to Date Generally, we use the date time object in PHP to convert the date
 

 

 

DMCA.com