This week's book giveaway is in the Other Languages forum.
We're giving away four copies of Functional Reactive Programming and have Stephen Blackheath and Anthony Jones on-line!
See this thread for details.
Win a copy of Functional Reactive Programming this week in the Other Languages forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

date problem

 
Dipse smith
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Sheriff
Pie
Posts: 20669
65
Chrome Eclipse IDE Java Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
Steve Luke
Bartender
Posts: 4181
22
IntelliJ IDE Java Python
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.

 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic