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 in advance

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
date_parse_from_format
  date_parse_from_format date_parse_from_format function returns... date_parse_from_format ( string $format , string $date ) Parameters of Date...;25.8.2009 17:00-03:00"; print_r(date_parse_from_format("j.n.Y H:iP"
ModuleNotFoundError: No module named 'odoo10-addon-hr-worked-days-from-timesheet'
ModuleNotFoundError: No module named 'odoo10-addon-hr-worked-days-from...: ModuleNotFoundError: No module named 'odoo10-addon-hr-worked-days-from-timesheet...-worked-days-from-timesheet' error? Thanks   Hi, In your python
ModuleNotFoundError: No module named 'odoo12-addon-hr-worked-days-from-timesheet'
ModuleNotFoundError: No module named 'odoo12-addon-hr-worked-days-from...: ModuleNotFoundError: No module named 'odoo12-addon-hr-worked-days-from-timesheet...-worked-days-from-timesheet' error? Thanks   Hi, In your python
ModuleNotFoundError: No module named 'odoo12-addon-hr-worked-days-from-timesheet'
ModuleNotFoundError: No module named 'odoo12-addon-hr-worked-days-from...: ModuleNotFoundError: No module named 'odoo12-addon-hr-worked-days-from-timesheet...-worked-days-from-timesheet' error? Thanks   Hi, In your python
ModuleNotFoundError: No module named 'odoo12-addon-hr-worked-days-from-timesheet'
ModuleNotFoundError: No module named 'odoo12-addon-hr-worked-days-from...: ModuleNotFoundError: No module named 'odoo12-addon-hr-worked-days-from-timesheet...-worked-days-from-timesheet' error? Thanks   Hi, In your python
ModuleNotFoundError: No module named 'odoo8-addon-hr-worked-days-from-timesheet'
ModuleNotFoundError: No module named 'odoo8-addon-hr-worked-days-from-timesheet...: ModuleNotFoundError: No module named 'odoo8-addon-hr-worked-days-from-timesheet...-days-from-timesheet' error? Thanks   Hi, In your python
ModuleNotFoundError: No module named 'odoo9-addon-hr-worked-days-from-timesheet'
ModuleNotFoundError: No module named 'odoo9-addon-hr-worked-days-from-timesheet...: ModuleNotFoundError: No module named 'odoo9-addon-hr-worked-days-from-timesheet...-days-from-timesheet' error? Thanks   Hi, In your python
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>>
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
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
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
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
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
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
Mysql Date Minus Days
elaborate an example from Mysql Date Minus Days. To understand the example, we... Mysql Date Minus Days       The Tutorial cover on Mysql Date Minus Days return you the day after
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 ExampleADS_TO_REPLACE_1 The Tutorial illustrate an example from 'Mysql
Mysql Date Add Days
Mysql Date Add Days       The Tutorial illustrate an example to add days to the particular days. Understand with ExampleADS_TO_REPLACE_1 In this section we are describing
Java convert string to date from format yyyy-mm-dd hh mm ss
Java convert string to date from format yyyy-mm-dd hh mm ss  Hi, I have date in the string yyyy-mm-dd hh mm ss format. Now I will want this string date into the date format. How to convert string to date from format yyyy-mm-dd
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
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
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
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
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
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 
ModuleNotFoundError: No module named 'angreal_meeting_minutes'
ModuleNotFoundError: No module named 'angreal_meeting_minutes'  Hi...: No module named 'angreal_meeting_minutes' How to remove the ModuleNotFoundError: No module named 'angreal_meeting_minutes' error? Thanks   
ModuleNotFoundError: No module named 'angreal_meeting_minutes'
ModuleNotFoundError: No module named 'angreal_meeting_minutes'  Hi...: No module named 'angreal_meeting_minutes' How to remove the ModuleNotFoundError: No module named 'angreal_meeting_minutes' error? Thanks   
ModuleNotFoundError: No module named 'angreal_meeting_minutes'
ModuleNotFoundError: No module named 'angreal_meeting_minutes'  Hi...: No module named 'angreal_meeting_minutes' How to remove the ModuleNotFoundError: No module named 'angreal_meeting_minutes' error? Thanks   
ModuleNotFoundError: No module named 'angreal_meeting_minutes'
ModuleNotFoundError: No module named 'angreal_meeting_minutes'  Hi...: No module named 'angreal_meeting_minutes' How to remove the ModuleNotFoundError: No module named 'angreal_meeting_minutes' error? Thanks   
ModuleNotFoundError: No module named 'angreal_meeting_minutes'
ModuleNotFoundError: No module named 'angreal_meeting_minutes'  Hi...: No module named 'angreal_meeting_minutes' How to remove the ModuleNotFoundError: No module named 'angreal_meeting_minutes' error? Thanks   
ModuleNotFoundError: No module named 'django-politico-minutes-editor'
ModuleNotFoundError: No module named 'django-politico-minutes-editor' ...: No module named 'django-politico-minutes-editor' How to remove the ModuleNotFoundError: No module named 'django-politico-minutes-editor' error
ModuleNotFoundError: No module named 'days'
ModuleNotFoundError: No module named 'days'  Hi, My Python program is throwing following error: ModuleNotFoundError: No module named 'days' How to remove the ModuleNotFoundError: No module named 'days' error
ModuleNotFoundError: No module named 'days'
ModuleNotFoundError: No module named 'days'  Hi, My Python program is throwing following error: ModuleNotFoundError: No module named 'days' How to remove the ModuleNotFoundError: No module named 'days' error
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
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
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
10 Minutes Guide to Ant
10 Minutes Guide to Ant       Introduction Well for the next 10 minutes get ready to devote... using Jboss 3.0 (with tomcat) downloaded from http://www.apache.org to deploy
How can I learn Java in 5 minutes
learn Java in 5 minutes? Thanks
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
Mysql Date Format codes
Mysql Date Format codes       The Tutorial illustrate an example from 'Mysql date format...; return you the date format in dd-mm-yy. mysql> select date_format

Ads