473,385 Members | 1,320 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

Date Checking

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
Nov 19 '08 #1
4 1518
r035198x
13,262 8TB
Have a look at GregorianCalendar, try some code and post again here if you still have problems.
Nov 19 '08 #2
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.setYear(oneYearAhead.getYear() + 1);

Should be noted that the setYear method here is actually deprecated .........
Nov 19 '08 #3
r035198x
13,262 8TB
Success!
...

Should be noted that the setYear method here is actually deprecated .........
... whereas the GregorianCalendar.roll method is not deprecated.
Nov 19 '08 #4
JosAH
11,448 Expert 8TB
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
Nov 19 '08 #5

Sign in to post your reply or Sign up for a free account.

Similar topics

5
by: Greg | last post by:
I have a page that searches a database by a repairman's name and by a date range. It pulls info by the repairman's name but pulls all info in the database regardless of the date. Below is the code...
4
by: Dave | last post by:
when I try to create an installation package for my program I get the warning that my c:\windows\system32\comdlg32.ocx and c:\windows\system32\mscomctl.ocx controls are out of date. I have...
4
by: Richard Hollenbeck | last post by:
I'm trying to write some code that will convert any of the most popular standard date formats twice in to something like "dd Mmm yyyy" (i.e. 08 Jan 1908) and compare the first with the second and...
30
by: Dr John Stockton | last post by:
It has appeared that ancient sources give a method for Numeric Date Validation that involves numerous tests to determine month length; versions are often posted by incomers here. That sort of code...
2
by: Riegn Man | last post by:
I have a problem with access and our time clocks. We have time clocks that put out a .log file with the badge swipes for everybody. There is one .log file for each day. I am pulling that data...
5
by: DataB | last post by:
Hi everyone, I have this piece of VBA script: ' checking the DOB field to see if we constrain on the date If Len(Me.EmpDOBTxt & "") > 0 Then strWhere = strWhere & " AND . <= #" & Me.DOBTxt &...
3
by: rcolby | last post by:
Hi all, I'm experiecing a problem with dates being returned from SQL 2000 Database. I retrieve the last updated field (Date) from a sql 2000 and then compare the returned date with another...
18
by: dfetrow410 | last post by:
Anyone have some code that will do this? Dave
6
by: leorulez | last post by:
I was wondering if there is any way in C to read the date and time (either system time or from the keyboard) and see if it falls between certain date and time? I am not sure how to compare the 2...
5
by: Øyvind Isaksen | last post by:
I have a page with an optional integer-field, and one asp:calendar control. I use a stored procedure to save the data in SQL Server. When all fields contains data, the code works great! But if the...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.