Solved

date function in jsp

Posted on 2004-03-23
3
957 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 60 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

Enroll in May's Course of the Month

May’s Course of the Month is now available! Experts Exchange’s Premium Members and Team Accounts have access to a complimentary course each month as part of their membership—an extra way to increase training and boost professional development.

Question has a verified solution.

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

Suggested Solutions

This is about my first experience with programming Arduino.
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 …
An introduction to basic programming syntax in Java by creating a simple program. Viewers can follow the tutorial as they create their first class in Java. Definitions and explanations about each element are given to help prepare viewers for future …
With the power of JIRA, there's an unlimited number of ways you can customize it, use it and benefit from it. With that in mind, there's bound to be things that I wasn't able to cover in this course. With this summary we'll look at some places to go…

738 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