Search...
FAQs
Subscribe
Pie
FAQs
Recent topics
Flagged topics
Hot topics
Best topics
Search...
Search within Java in General
Search Coderanch
Advance search
Google search
Register / Login
Bookmark Topic
Watch Topic
New Topic
programming forums
Java
Mobile
Certification
Databases
Caching
Books
Engineering
Micro Controllers
OS
Languages
Paradigms
IDEs
Build Tools
Frameworks
Application Servers
Open Source
This Site
Careers
Other
Pie Elite
all forums
this forum made possible by our volunteer staff, including ...
Marshals:
Campbell Ritchie
Jeanne Boyarsky
Ron McLeod
Paul Clapham
Liutauras Vilda
Sheriffs:
paul wheaton
Rob Spoor
Devaka Cooray
Saloon Keepers:
Stephan van Hulst
Tim Holloway
Carey Brown
Frits Walraven
Tim Moores
Bartenders:
Mikalai Zaikin
Forum:
Java in General
Caldendar.before() method
Veena Ka
Greenhorn
Posts: 3
posted 12 years ago
Number of slices to send:
Optional 'thank-you' note:
Send
I have this peice of code that , that I want to validate if the date is before the given date or not. But dont know why it keeps returning false.
Date wrksDate = wbData.getWrksWorkDate(); Calendar calWrksDate = Calendar.getInstance(); calWrksDate.setTime(wrksDate); Calendar marchCal = Calendar.getInstance(); marchCal.set(Calendar.MONTH, Calendar.MARCH); marchCal.set(Calendar.DAY_OF_MONTH, 31); marchCal.set(Calendar.YEAR, calWrksDate.get(Calendar.YEAR)); Date dt = marchCal.getTime(); Date dt1 = calWrksDate.getTime(); logger.info("******March Calendar *******" +dt); logger.info("******March Calendar *******" +dt1); logger.info("******March Calendar *******" +wrksDate.before(marchCal.getTime())); if (wrksDate.before(calWrksDate.getTime())) return true; else return false;
The date that I am providing is 5th of Feb.
Can anyone please help?
Maneesh Godbole
Bartender
Posts: 11497
19
I like...
posted 12 years ago
Number of slices to send:
Optional 'thank-you' note:
Send
Duplicate of
https://coderanch.com/t/555117/java/java/Date-before-Function
Please
UseOneThreadPerQuestion
[
How to ask questions
] [
Donate a pint, save a life!
] [
Onff-turn it on!
]
I child proofed my house but they still get in. Distract them with this tiny ad:
a bit of art, as a gift, that will fit in a stocking
https://gardener-gift.com
Bookmark Topic
Watch Topic
New Topic
Boost this thread!
Similar Threads
finding date diff
problem comparing date values
How to get end week date from given start date??
Is there a better way to calculate age?
java calander class
More...