Home Answers Viewqa Date-Calendar Date related query

 
 


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

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 Pages:
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
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
liferay related query
liferay related query  can you suggest me how to get all the session ids of different users logged in to liferay
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
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
related to database
related to database  how to override existing values in table? when user enters his updated data through query
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
Query
); p6=new JPanel(); l6=new JLabel("Date of Birth"); p6.setLayout
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
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
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
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
session into a query
calling one session variable in mysql query but its not working can any one help me please... here is the query.. $query = 'SELECT * FROM post WHERE post_date < "'.$as.'" and posttitle like "%$SESSION['qs']%" ORDER BY post_date DESC LIMIT
Database related issue - Development process
Database related issue  I have view in db2 database and i am firing a select query on this view with two timestamps which fetches all the rows... fetched by previously running the select query on this view. Please can somebody
XML Related Technologies: An overview
XML Related Technologies: An overview       Below is a list of XML-related technologies. DTD... document. XForms (XML Forms) uses XML to define form data. XQuery (XML Query
Date format - Date Calendar
Date format  please convert dd-mmm-yy date format to gregorian calendar date format.  Hi friend, Code related your Problem: import...]); Calendar calendar = new GregorianCalendar(pdt); Date time = new Date
jdbc & sql related project - JDBC
from a list and execute any sql query related to the selected database e.g... to execute any query related to student database i.e. the odbc driver should support...jdbc & sql related project  code using jdbc,odbc,swing,MySql classes
project query
project query  I am doing project in java using eclipse..My project is a web related one.In this how to set sms alert using Jsp code. pls help me
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>
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
Mysql Date from Date
'. To grasp this example, we use date(current_trimestamp ( )) query that return you the current date  from date time as Date field name. Query... Mysql Date from Date      
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
dynamic query
dynamic query  DECLARE QUERY VARCHAR2(32767); FIN_QUERY VARCHAR2...; PORTFOLIO_LEVEL ARRAY; IDX NUMBER :=1; BEGIN QUERY..._LEVEL; IDX := IDX + 1; END IF; END LOOP; QUERY := QUERY
sql query
); this is the query i have written for the table "dpscomp" - station date month...sql query  SQL QUERY BROWSER declare @cout00 int declare @cout01 int declare @cout10 int declare @cout11 int declare @c1 float declare @gss float
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 between
of my fields is date_, and the type of the field is DateTime. When I want to select records between 2 dates, I use this query: Select * from table1 Where date...date between  Hi Iââ?¬â?¢ve wrote a program by Delphi 7, Iââ?¬â?¢ve
JPA delete query - EJB
to delete all the records from the table. What will be the JPA query to delete... flexible and it provides required API for perform database related operations... to achieve this: Query query = em.createQuery("delete from InvoiceItems o
SQL QUERY ERROR
SQL QUERY ERROR  Im writing a query which shows error of INVALID CHARACTER The Query is Insert into PMST_EMP_MST(PMSNUM_EMP_ID,PMSSTR_EMP_NAME,PMSDT_DOB_DATE,PMSSTR_GENDER,PMSNUM_DESIGNATION_CODE,PMSNUM_CDAC_EMPID
Mysql Date Subtract
) : The Query is used to return the date before the current date. The INTERVAL is used to subtract the number of days specified in interval from the current date. Query... Mysql Date Subtract      
project on php and query
query betwen them this five tabels Table of suppliers Source no resource... Delivery date notes Table purchases Purchase invoice number Date Number of purchase number statement item Price color payment Delivery date notes
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
php inserting date into mysql
(dp_name, dp_date) VALUES ('DATE: Manual Date', '2020-2-14')"; $query_auto...php inserting date into mysql  php inserting date into mysql   Here is a php code that inserts date into mysql database. In the given code
jsp query - JSP-Servlet
jsp query  in first division there is one table which contains data with edit button... when i will click on edit button that division will become hidden and new division come with all related data
Timestamp value and query
Timestamp value and query  convert a string to timestamp and pass it into database settimestamp value We get a string from jsp.The string value is a date and time value. Convert the string value to a timestamp and a query
SQL Date, SQL Date Examples
Date Today in My sql. The Query used in the below example the now... 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 date
SQl Date
; in the database. The query contain only the date portion, which you want... SQL Date       The SQL Date is used when you are working with dates. This include
need search query - WebSevices
; create table stu(name varchar(10), dob date); insert into stu values('komal... { public static void main(String args[]) { int date = 27; int..."; String pass = "root"; Date dob = new Date(1); try
Mysql Date Name
the current date of the month. date_format(now( ),'%e') : The Query return you the current date of the month.  Query for selecting date from the current... Mysql Date Name      

Ask Questions?

If you are facing any programming issue, such as compilation errors or not able to find the code you are looking for.

Ask your questions, our development team will try to give answers to your questions.