wood burning stoves 2.0*
The moose likes Java in General and the fly likes Program for date comparison Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Java » Java in General
Bookmark "Program for date comparison" Watch "Program for date comparison" New topic

Program for date comparison

sridhar Ranganathan

Joined: Feb 06, 2008
Posts: 29
I have attached the code of date comparison,somebody asked this pgm.
Iam unable to post this.

In this pgm ,Getting two dates(from and to) input from console storing in string variable.comparing the two date fields.

import java.util.*;
import java.io.*;
import java.text.ParseException;
import java.text.SimpleDateFormat;
class dc
public static void main(String ae[])throws IOException
BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
System.out.println("Enter the From Date [Format DD-MM-YYYY]");
String fromDate=br.readLine();
System.out.println("Enter the To Date [Format DD-MM-YYYY]");
String toDate=br.readLine();
SimpleDateFormat form=new SimpleDateFormat("dd-MM-yyyy");
Date sysdate=new Date();
System.out.println("\t\tDATE COMPARISON ");
System.out.println("\tFROM DATE :- "+form.format(form.parse(fromDate)));
System.out.println("\tTO DATE :- "+form.format(form.parse(toDate)));
System.out.println("======================================================== ");

System.out.println("\tFROM DATE IS LESS THEN TO DATE ");
System.out.println("\tFROM DATE IS GREATER THEN TO DATE ");
System.out.println("======================================================== ");
catch(ParseException pe)
System.out.println("Parse Exception : " + pe);

Jesper de Jong
Java Cowboy
Saloon Keeper

Joined: Aug 16, 2005
Posts: 14074

Code tags on JavaRanch require [ and ] brackets, not < and >.

But why are you posting this here, do you have a question?

Java Beginners FAQ - JavaRanch SCJP FAQ - The Java Tutorial - Java SE 7 API documentation
Scala Notes - My blog about Scala
sridhar Ranganathan

Joined: Feb 06, 2008
Posts: 29

Somebody asked this program,Iam unable to reply to him.That is why i posted
here.This will help for someone.

I agree. Here's the link: http://aspose.com/file-tools
subject: Program for date comparison
Similar Threads
Problem in setting the date in a servlet
Any Alternative for this CODE !!!!!!
how to convert a string to date
Date manipulation problem
Date; Previous date, Calendar; Gregorian