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



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

View Questions and Answers by Category

Advertisements


 
Have Programming Question? Ask it here!
 
 
 


raveen
converstion from minutes to days format
1 Answer(s)      3 years 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>>
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
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
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
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
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
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
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
Advertisements
 

 

 

DMCA.com