May 16, 2008 at 7:53 PM
Hi
import java.util.*;
import java.util.Calendar;
public class DeltaDays {
public static void main(String[] args) {
// Creates two calendars instances
Calendar calendar1 = Calendar.getInstance();
Calendar calendar2 = Calendar.getInstance();
// Set the date for both of the calendar instance
calendar1.set(2007, 12, 30);
calendar2.set(2008, 05, 03);
// Get the represented date in milliseconds
long milis1 = calendar1.getTimeInMillis();
long milis2 = calendar2.getTimeInMillis();
// Calculate difference in milliseconds
long day = milis2 - milis1;
// Calculate difference in seconds
long diffSeconds = day / 1000;
// Calculate difference in minutes
long diffMinutes = day / (60 * 1000);
// Calculate difference in hours
long diffHours = day / (60 * 60 * 1000);
// Calculate difference in days
long diffDays = day / (24 * 60 * 60 * 1000);
System.out.println("In milliseconds: " + day + " milliseconds.");
System.out.println("In seconds: " + diffSeconds + " seconds.");
System.out.println("In minutes: " + diffMinutes + " minutes.");
System.out.println("In hours: " + diffHours + " hours.");
System.out.println("In days: " + diffDays + " days.");
}
}
---------------------------------
read for more information.
http://www.xmission.com/~goodhill/dates/deltaDates.html
Related Tutorials/Questions & Answers:
calculate difference between two datescalculate difference between two dates hi,
I was actually working on to
calculate the number of days
between two dates of dd/mm/yyyy format... the
difference between the
two dates Advertisements
Hi .Difference between two Dates - Java BeginnersHi .
Difference between two Dates Hi Friend....
Thanks for ur Very good response..
Can u plz guide me the following Program....
difference between two dates..
I need to display the number of days by Each Month
Javascript calculate number of days between two datesJavascript
calculate number of days
between two dates
In this tutorial, you will learn how to
calculate number of days
between two
dates.For this, you need... using Date.getTime() function. Once both
Dates have been
converted, subtracting
Difference in two dates - Java Beginners on that.
The thing is, that I need to find the
difference between the
two dates in
JAVA... the
difference between two dates.
public class DateDiffDemo {
public static...
Difference in
two dates Hello there once again........
Dear Sir
display dates between two dates - Java Beginnersdisplay
dates between two dates hi
can any one help me to writing this code, i need to store the
dates between to
dates so that i can retrive the data from the db using theses
dates.
its urgent pls tell me as possible
list of all months between two dates in javalist of all months
between two dates in java Hi,
I want to get list of all months with year
between two dates.
How to do this in
Java?
Thanks
Hi,
This is the example code which can be used:
package test.app
list of all months between two dates in javalist of all months
between two dates in java Hi,
I want to get list of all months with year
between two dates.
How to do this in
Java?
Thanks
Hi,
This is the example code which can be used:
package test.app
How to select Data Between Two dates in Java, MySQLHow to select Data
Between Two dates in
Java, MySQL How to select Data
Between Two dates in
Java, MySQL?
Thanks in advance.
http://www.v7n.com/forums/coding-forum/294668-how-select-data-
between-
two-
dates-php
mysql difference between two numbersmysql
difference between two numbers How to get total bate
difference between two dates for example 1/01/2012 and 1/02/2012 in MYSQL?
...
between two date. The syntax of DATEDIFF is ..
SELECT DATEDIFF('2012-01-31 23:59
How to calculate Date Difference in Java?How to
calculate Date
Difference in
Java? Hi,
I have
two dates variable. How to
calculate Date
Difference in
Java?
Thanks
Hi,
You can use the Calendar class for calculating the date
difference in
Java.
Get data
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 Java Swing Date DifferenceJava Swing Date
Difference
In this tutorial, you will learn how to find the
difference between two
dates. Here is an example that accepts
two dates from... the following method that
calculates the date
difference in terms of days
Mysql Time Difference Function difference between
any
two dates.
Understand with ExampleADS_TO_REPLACE_1
The Tutorial... that return you the time
difference between any
two
consecutive
dates.
TimeDiff('Year1 Time1', 'Year2 Time2') : The Query performs the time
difference between mysql between dates not between datesmysql
between dates not
between dates I am trying to list the data
between dates and not
between dates using join method ..but that not working for me
Comparing two dates in javaComparing
two dates in
java
In this example you will learn how to compare
two dates in
java.
java.util.Date provide a method to compare
two dates... date. The
example below compares the
two dates.
import
Java get number of days between dates Java get number of days
between dates
... the number of days
between
the
two described
dates.
In order to get the number of days
between two dates, the given example has
set
two dates by using
difference between wite and writeto in javadifference between wite and writeto in java I am using the stream... the writeTo() method. I want to know
difference between the write() and writeTo() method in
java.
The writeTo() method writes the complete contents
What is difference between the java and javascript?What is
difference between the
java and javascript? What is the
difference beteen the
java and javascript?
Hello Friend,
Difference:ADS_TO_REPLACE_1
1)
Java is a Object Oriented programming language developed
Comparing two Dates in Java
Comparing
two Dates in
Java
In this example we are going to compare
two date
objects using java.util.Date class. For comparing
dates, we will be using compareTo
Date Difference
Date
Difference
This example learns how to make the
difference
between two dates and how... Object
class and makes a
difference between a Date object and a set of integer