This week's book giveaway is in the Servlets forum.
We're giving away four copies of Murach's Java Servlets and JSP and have Joel Murach on-line!
See this thread for details.
The moose likes Beginning Java and the fly likes Date help Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "Date help" Watch "Date help" New topic
Author

Date help

shah rah
Ranch Hand

Joined: Jan 04, 2007
Posts: 124
I need to display page depending on dates

between todays date and June 15 2009 ---I need to display page1.htm

after june 15 2009 I need to display page2.htm

here is what I have done: get

month =Integer.parseInt(sdf.format(currdate));
day =Integer.parseInt(sdf.format(currdate));
year =Integer.parseInt(sdf.format(currdate));

if( (month>=6)&& (day>=1) &&(year!=2008)){
show page1.htm
else
show page2.htm

This is not working if i have current date as Jan 11 2010
Joanne Neal
Rancher

Joined: Aug 05, 2005
Posts: 3416
    
  12
Originally posted by shah rah:
I need to display page depending on dates

between todays date and June 15 2009 ---I need to display page1.htm

after june 15 2009 I need to display page2.htm

here is what I have done: get

month =Integer.parseInt(sdf.format(currdate));
day =Integer.parseInt(sdf.format(currdate));
year =Integer.parseInt(sdf.format(currdate));

if( (month>=6)&& (day>=1) &&(year!=2008)){
show page1.htm
else
show page2.htm

This is not working if i have current date as Jan 11 2010


You're calling the same methods with the same data to calculate month, day and year. Won't this make month, day and year all have the same value ?


Joanne
shah rah
Ranch Hand

Joined: Jan 04, 2007
Posts: 124
my current date is like 2008-12-03-00.00.00

I am extracting month day and year from the above
Joanne Neal
Rancher

Joined: Aug 05, 2005
Posts: 3416
    
  12
Originally posted by shah rah:
my current date is like 2008-12-03-00.00.00

I am extracting month day and year from the above


I would expect these three lines of codeto set month, day and year to the same value, so the first thing you should check is whether the values of those 3 variables are what you expect them to be.
[ December 03, 2008: Message edited by: Joanne Neal ]
 
 
subject: Date help
 
Similar Threads
How to display date in Daylight Savings
Date problem
A question on java.util.Date
add one day to current date
formatting challenge using JSpinner