File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes JSP and the fly likes Calculate Date having DIFFERENT DATE FORMATS  Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of EJB 3 in Action this week in the EJB and other Java EE Technologies forum!
JavaRanch » Java Forums » Java » JSP
Reply locked New topic

Calculate Date having DIFFERENT DATE FORMATS

Mehak Daani

Joined: Oct 08, 2003
Posts: 16
Hi ....
I want to calculate date difference between 2 DIFFERENT DATE FORMATS ... one of my date format is "yyyy/mm/dd" and the other date format is "yyyy/mm/dd hh:mm:ss" ............... how can i calcaulate the difference between these two dates and then display the result in a String in the format of yyyy/mm/dd ???.???
more over i want to make a comparision also ... like if(date1 > date 2) .. then i = 1 else i =0;
So i want help on 2 things .....
1. Finding difference
2. Comparing and then incrementing value of a temp variable.
plz some one help me out on this .........................

Mehak Daani

Joined: Oct 08, 2003
Posts: 16
Ok .... I have converted the both the dates to the same format ... now how do i COMPARE them ...???
William Brogden
Author and all-around good cowpoke

Joined: Mar 22, 2000
Posts: 12675
Look at the methods in the java.util.Date class.
Bear Bibeault
Author and ninkuma

Joined: Jan 10, 2002
Posts: 60050

This is pretty much the same question you posted a little while ago (and which has been moved to the Java in General/Intermediate forum). Please do not post the same question multiple times in either the same, or across multiple, forums.

[Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]
I agree. Here's the link:
subject: Calculate Date having DIFFERENT DATE FORMATS
Similar Threads
using parse() from DateFormat
string to timestamp
How to change Date Format
Code review required for converting dateformat