Date related query

Date related query

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... an example from 'Mysql Date Query'. To understand this example we use current
jtable query compare with date
jtable query compare with date  how to transfer daytable data to monthtable when complete a month
ModuleNotFoundError: No module named 'date-query'
ModuleNotFoundError: No module named 'date-query'  Hi, My Python... 'date-query' How to remove the ModuleNotFoundError: No module named 'date... have to install padas library. You can install date-query python
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 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. ... the today current date. date (now ( )) : The Query now ( )   return you the current today date in Mysql. Query for finding the current date:-ADS
Mysql Date Add
an example from 'Mysql Date Add'. To grasp this example we use query AddDate... Mysql Date Add       Mysql Date Add is used to add the days  to the date specified
SQL Date, SQL Date Examples
Date Today in My sql. The Query used in the below example the now... an example from 'Mysql Date Month'. In this Example, The Query month (now... Days. To understand the example, we use the select date(now( )) Query that return
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
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
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
StringBuffer related.
StringBuffer related.  how to make StringBuffer as immutable
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
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
date
database table name birthday (DOB date); dob with DATE data type in database while...=d.getTime(); java.sql.Date date = new java.sql.Date(t); try { System.out.println(date); Class.forName("oracle.jdbc.OracleDriver"); con
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
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
Mysql Date Format Convert
;  You already Know with the Query to find the current date... ( ) Query that return you the current today date and time. now ( ) : The Query now ( ) return you the current date and time Query for finding current date
Mysql Date Quarter
Mysql Date Quarter       Mysql Date Quarter is a query in SQL that is used to show Quarter... 4 Query to show Quarter  date range 1 to 4
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... Mysql Date Format      
Mysql Date Only
this example, we create an example that include a Query date (now ( )) ... ( )) return you  a current date value as Date Only field name.  Query... Mysql Date Only      
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 Questions
Related Questions  Hi, I am beginner in Data Science and machine learning field. I am searching for the tutorials to learn: Related Questions... "Related Questions". Also tell me which is the good training courses
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
query
; Container cp=null; JPanel p=null; JLabel months3=null,date=null,ghba1c=null,per=null... JLabel("3 Months-Report"); date=new JLabel("Date"); ghba1c=new JLabel("GHbA1c"); per... Object colheads[]={"Date","%"}; final Object rowdata
Query
); p6=new JPanel(); l6=new JLabel("Date of Birth"); p6.setLayout
Mysql Date from Date
_trimestamp ( )) query that return you the current date  from date time as Date... Mysql Date from Date       Mysql  Date from Date Time in Mysql return the Current 

Ads