File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Beginning Java and the fly likes Date range help Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "Date range help " Watch "Date range help " New topic

Date range help

Connie Kamrowski

Joined: Aug 15, 2004
Posts: 23

I need some help to figure out how to solve my problem.

I have a system which stores details of projects. For each project you have a start and end date and an allocation out of 100 which indicates you time on the project.

When I add a new project I need to go and check if the date range of the new project is inside the date range of any other entry for you, if it is I need to add the proposed allocation to your already stored allocations and see if that totals over 100, if so I need to flag that it totals over 100 and for what dates this occurs and present that back to the user.

I have not used the date functionality in Java and so am unsure how to start

**How much deeper would the ocean be if Sponges didn't grow in it?**
Purushoth Thambu
Ranch Hand

Joined: May 24, 2003
Posts: 425
Can you share the class? Not sure how the date fields are populated and what data type. You can use getTime() in java.util.Date class. Look at Date class for more details.
Connie Kamrowski

Joined: Aug 15, 2004
Posts: 23
I am using Hibernate as a middle tier and so my values are all stored in Hibernate objects. I have an object called ProjectAllocation which has your name as ResourceNm, the project name as ProjectNm, a Start Date as StartDt and an End Date as EndDt and an Allocation.

One person can have many objects for their name.

When I am adding a new entry I need to check and see if this will make the resource over allocated.

so I have a new start and End date which I wish to add and a new allocation. This is what I have so far:

So in the code I have got the objects and then pulled the start and end dates and allocation

what I need to do now is to compare the start and end input dates to the ones I have in the database and if they overlap, check if the allocation stored plus the new allocation is over 100, if so warn the user and ask if they still want to add the project, if they say yes then I want to add the record but change the color in the displaypage to red.

Ideally I would like to check week against week. I had read somewhere that I can convert a date range to week of year and then do an overlap but I have no idea how to start.
I agree. Here's the link:
subject: Date range help
jQuery in Action, 3rd edition