aspose file tools
The moose likes Java in General and the fly likes date problem Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of Elasticsearch in Action this week in the Big Data forum!
JavaRanch » Java Forums » Java » Java in General
Bookmark "date problem" Watch "date problem" New topic

date problem

Dipse smith

Joined: Mar 12, 2008
Posts: 5
I have the day of week (eg monday),week of year (eg 41) and year (eg 2007)
From this I want to calculate the date in the form dd/MM/yyyy but i am not sure how to do this.
Searches on google and such have not provided me with a solution to my problem.
What I attempted to do was take the week of year and find the date of the monday of that week and work from there. However i could not get this to work and was wondering if there was another way.

Thanks in advance for any help.
Rob Spoor

Joined: Oct 27, 2005
Posts: 19908

Check out java.util.Calendar, java.util.Date and java.text.(Simple)DateFormat.
In short:
- create a Calendar instance
- set the values of that Calendar instance
- retrieve a Date from that Calendar instance
- create a DateFormat
- format the Date

How To Ask Questions How To Answer Questions
Steve Luke

Joined: Jan 28, 2003
Posts: 4181

Use a Calendar to get a representation of the specific date you need (setting the year, week in year, and day of week fields). Then when you have it configured get a Date object from the Calendar and use DateFormat to output a String in the format you want.

Don't get me started about those stupid light bulbs.
subject: date problem