Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

date function in jsp

Posted on 2004-03-23
3
Medium Priority
?
962 Views
Last Modified: 2008-01-09
how to write date function injsp
can u pls send me code for checking date .
i.e date diffrence should not be greater then 3 days.
pls its urgent
0
Comment
Question by:sameerasawant
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
3 Comments
 
LVL 3

Accepted Solution

by:
yasser_helmy earned 240 total points
ID: 10659899
Since you said jsp.. i ll assume you are talking about the java part, not the html part..
you can use the java.util.Calendar and java.util.Date classes for date handling..

Calendar c1 = Calendar.getInstance(); //current date
Calendar c2 = Calendar.getInstance(); //other date

c2.set(2004, 02, 23); //set date to 23 april 2004
                               // as the month is 0-based
Date d1= c1.getTime(); //get Date object for c1
Date d2 = c2.getTime(); //get Date object for c2

long millis1 = d1.getTime();  //get number of millis
long millis2 = d2.getTime();  //get number of millis

long diff = millis1 - millis2; //difference between the dates in millseconds
if (diff > 3*24*60*60*1000) { //difference does not exceed 3 days
   //add code here
} else {
   //add code here
}
0

Featured Post

Build and deliver software with DevOps

A digital transformation requires faster time to market, shorter software development lifecycles, and the ability to adapt rapidly to changing customer demands. DevOps provides the solution.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Although it can be difficult to imagine, someday your child will have a career of his or her own. He or she will likely start a family, buy a home and start having their own children. So, while being a kid is still extremely important, it’s also …
The SignAloud Glove is capable of translating American Sign Language signs into text and audio.
Six Sigma Control Plans
Starting up a Project

660 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question