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



Home Answers Viewqa Date-Calendar Date related query

Have Programming Question? Ask it here!
 
 
 


santosh
Date related query
1 Answer(s)      5 years and 5 months ago
Posted in : Date-Calendar



Advertisement
View Answers

December 14, 2008 at 11:49 PM


Hi friend,

Code to solve the Problem :

import java.util.Date;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.io.*;

public class DayDiff {

public static void main(String[] args) throws IOException{

BufferedReader br=new BufferedReader(new InputStreamReader(System.in));

//string containing date in one format

System.out.println("Enter Start Date in Format DD/MM/yyyy");
String strDate2 =br.readLine();
System.out.println("Enter End Date in Format DD/MM/yyyy");
String strDate1 = br.readLine();


try
{
//create SimpleDateFormat object with source string date format
SimpleDateFormat sdfSource = new SimpleDateFormat("DD/MM/yyyy");

//parse the string into Date object
Date date1 = sdfSource.parse(strDate1);
Date date2 = sdfSource.parse(strDate2);


long diff = date1.getTime() - date2.getTime();

long diffDays = diff / (24 * 60 * 60 * 1000);

System.out.println("diffDays : " + diffDays);

}
catch(ParseException pe)
{
System.out.println("Parse Exception : " + pe);
}
}
}



Thanks


Related Tutorials/Questions & Answers:
Date related query - Date Calendar
Date related query  hi, m a new biginner of java.i m intrested... user using bufferedReader. how can i convert a string into a date object.pls... Date { public static void main(String ar[]) { Date d1=new Date
query related to uploading file
query related to uploading file  hello friends i am doing my project in servlet and i want to upload a file and store file in local hard drive... to save the uploading time and date in database. please help me it is urgent
Advertisements
JDBC related query
JDBC related query  How to merge two resultset of two different queries, wherein both the resultset(after query execution)gives an integer value as its column
query related to jdbc
query related to jdbc  hello, i have done my database connection successfully ie db2 with RAD. but while running my application i am not able to fetch the data so please suggest and help me
query related to awt
query related to awt  Hi, I want to know how to check a text value is numeric or not when user enters the text to the textbox.After checking whether the enter text is numeric we need to display in LwDialog showing proper
liferay related query
liferay related query  can you suggest me how to get all the session ids of different users logged in to liferay
database related query
database related query  i have created database in phpmyadmin of wampserver ! but i can't see it in mysql command line ! Can anybody please help me
Hibernate Query related
Hibernate Query related  Actully i want to retrieve data from multiple file by using this query: SELECT a.PROD_ID AS Product_Id, b.PROD_N AS Product_Name, c.MEDIA_URL AS Image_url, d.SAL_AMT AS Product
query related to roseindia example - Ajax
query related to roseindia example  http://www.roseindia.net/ajax/File-Upload.shtml In FileUploadServlet.java where is "fileupload package" I am getting error on "import org.apache.commons.fileupload.disk.DiskFileItemFactory
Frame related query - Java Beginners
Frame related query  hi..... i m having a query dat...can i open a frame inside another frame like dis.. m a new biginner of java n m finding it very intresting. my lines of codes are like dis:- import java.awt.*; import
Mysql Date Query
Mysql Date Query       Mysql Date Query Date Query is used to return the current date, month and year... 'Mysql Date Query'. To understand this example we use current_date query
SQL date query
SQL date query  how to get ( 15 march 2011) and (15/03/2011) output... in the given format. For (15 march 2011) format: SELECT DATE_FORMAT(dob, '%d %M %Y') FROM patient; For (15/03/2011) format: SELECT DATE_FORMAT(dob, '%d/%m/%Y
jtable query compare with date
jtable query compare with date  how to transfer daytable data to monthtable when complete a month
jtable query compare with date
jtable query compare with date  how to transfer daytable data to monthtable when complete a month Hello Sir, I am developing a desktop application in which i have to display database records in jtable .now I want to transfer
jtable query compare with date
jtable query compare with date  how to transfer daytable data to monthtable when complete a month Hello Sir, I am developing a desktop application in which i have to display database records in jtable .now I want to transfer
jtable query compare with date
jtable query compare with date  how to transfer daytable data to monthtable when complete a month Hello Sir, I am developing a desktop application in which i have to display database records in jtable .now I want to transfer
SQL display date in between query
SQL display date in between query  how to get ( 15 march 2011) and (15/03/2011) output using SQL
How to execute my query fast..When A date filter is there in a query it takes more time for execution.?
How to execute my query fast..When A date filter is there in a query it takes more time for execution.?  When A date filter is there in a query it runs for 10 mins with 4000 records.. when the date filter is commented it runs
related to database
related to database  how to override existing values in table? when user enters his updated data through query
Mysql Date Today
; Mysql Date Today show you Query to retrieve the current today date. ... date. date (now ( )) : The Query now ( )   return you the current today date in Mysql. Query for finding the current date:- mysql>
Mysql Date Add
Mysql Date Add       Mysql Date Add is used to add the days  to the date specified in query. Understand with Example The Tutorial illustrate an example from 'Mysql Date Add
SQL Date, SQL Date Examples
'Mysql Date Month'. In this Example, The Query month (now( )) returns you value... the example, we use the select date(now( )) Query that return the current... an example that help you in writing a date time format Query in different ways
query
; Container cp=null; JPanel p=null; JLabel months3=null,date=null,ghba1c=null,per=null...-Report"); date=new JLabel("Date"); ghba1c=new JLabel("GHbA1c"); per=new JLabel...[]={"Date","%"}; final Object rowdata
Date Class In Action Script
class that provide date and time related information. User access the current... date and time related information. we can access and manipulate the date... .style1 { font-size: medium; } Date Class in Action Script 3:- If user
Query
); p6=new JPanel(); l6=new JLabel("Date of Birth"); p6.setLayout
JDBC : Current Date
JDBC : Current Date In this section, you will learn query for current date. Display Current Date : There are various methods provided by MYSQL to get current date. These are CURRENT_DATE, CURRENT_DATE(), CURRENT_TIMESTAMP, CURRENT
StringBuffer related.
StringBuffer related.  how to make StringBuffer as immutable
project related question
project related question  1- how to insert a date through hibernate 2- how to insert exact time ,date separetly in the data base for current time date
Related to Histogram
Related to Histogram  hi this is srinivasrao. In my project i have to display using chart for that i want to use histogram. k chart displayed but the values given by me is not related display chart so please give the code if u
related to java
related to java  what is mean of }); in java.i know that } is used to close a block of statement,) is used to close a statement and ";"is used after close a statement but i can not usderstood the use of }); together in a java
Related to Project
Related to Project  how speech to text project can be make in java? Please tell me the coding part therapeutically i know i have to use java speech api which offer two technology 1. speech recognization 2. speech syenthesis
Related to XML
Related to XML  I have made a web application which send the SMS, i have provided the url in which i have to save the msg and the number's(to whom the message to be send).After fetching the message and numbers i was keeping
Related to XML
Related to XML  I have made a web application which send the SMS, i have provided the url in which i have to save the msg and the number's(to whom the message to be send).After fetching the message and numbers i was keeping
date
date   how to insert date in database? i need coding
date
date  can u tell me how to calculate difference between a user provided date and the system date in java
date
date  can u tell me how to calculate difference between a user provided date and the system date in java
date
date  i want difference between the date entered in a jtextfield and the system date in java
date
date  how to insert date using html through the combobox
date
date  how to insert date using html through the combobox
date
date  how to insert date using html through the combobox
date
date  how to insert date using html through the combobox
Mysql Date Format Convert
;  You already Know with the Query to find the current date... 'Mysql Date Format Convert'. To grasp this concept we use Date now ( ) Query that return you the current today date and time. now ( ) : The Query now ( ) return
Mysql Date Quarter
Mysql Date Quarter       Mysql Date Quarter is a query in SQL that is used to show Quarter date range... Oct-Dec 4 Query to show Quarter  date range 1 to 4
Mysql Date Only
create an example that include a Query date (now ( ))  returns you... you  a current date value as Date Only field name.  Query... Mysql Date Only      
Mysql Date Format
. The Tutorial helps you to write the Date Format in SQL Querydate_format(now( ),'%e %M%W%Y') : This Query is used to display the current date, month, week and year.  Query for formatting currentdate:- mysql> select date
DATE
DATE  I have the following as my known parameter Effective Date... of calcultion starts My question is how to find the date of Thursday This cycle... the date of all the thursdays of the given year. import java.util.*; import
Dumps related to weblogic certification
Dumps related to weblogic certification   I want to perform the weblogic certification exam code 1z0-110. Can anybody please provide me the dumps related to 1z0-110 Thanks in advance
Java and jvm related question
Java and jvm related question  What is difference between java data types and jvm data types
question related to overloading
question related to overloading  what is difference between function overloading & method overloading
question related to overloading
question related to overloading  what is difference between function overloading & method overloading
Advertisements
 

 

 

DMCA.com