Login or Sign Up
Logging in...
Remember me
Log in
Or
Sign Up
Forgot password or user name?
Log in with
Search in titles only
Search in Java only
Search
Advanced Search
Forums
BYTES
Product Launch
Updates
Developer Toolkit
Today's Posts
Member List
Calendar
Home
Forum
Topic
Java
Date Checking
Collapse
X
Collapse
Posts
Latest Activity
Photos
Page
of
1
Filter
Time
All Time
Today
Last Week
Last Month
Show
All
Discussions only
Photos only
Videos only
Links only
Polls only
Events only
Filtered by:
Clear All
new posts
Previous
template
Next
javaEddie
New Member
Join Date:
Nov 2008
Posts:
2
#1
Date Checking
Nov 19 '08, 11:37 AM
I need to ensure that a date entered is within the next calendar year. If it is more than one year ahead it has to be rejected - can anyone help with how to achieve this?
Thanks alot
r035198x
MVP
Join Date:
Sep 2006
Posts:
13225
#2
Nov 19 '08, 12:16 PM
Have a look at GregorianCalend ar, try some code and post again here if you still have problems.
Comment
Post
Cancel
javaEddie
New Member
Join Date:
Nov 2008
Posts:
2
#3
Nov 19 '08, 02:06 PM
Success!
After a few attempts at different potential solutions, the below appears to have worked, didn't even need to use a calendar in the end :
Date oneYearAhead = new Date();
oneYearAhead.se tYear(oneYearAh ead.getYear() + 1);
Should be noted that the setYear method here is actually deprecated .........
Comment
Post
Cancel
r035198x
MVP
Join Date:
Sep 2006
Posts:
13225
#4
Nov 19 '08, 02:11 PM
Originally posted by
javaEddie
Success!
...
Should be noted that the setYear method here is actually deprecated .........
... whereas the GregorianCalend ar.roll method is not deprecated.
Comment
Post
Cancel
JosAH
Recognized Expert
MVP
Join Date:
Mar 2007
Posts:
11453
#5
Nov 19 '08, 02:25 PM
Originally posted by
javaEddie
Should be noted that the setYear method here is actually deprecated .........
... so maybe at Java's next update your 'solution' might not work anymore.
kind regards,
Jos
Comment
Post
Cancel
Previous
template
Next
Working...
Yes
No
OK
OK
Cancel
👍
👎
☕
Comment