This week's book giveaway is in the OCAJP forum.
We're giving away four copies of Programmer's Guide to Java SE 8 Oracle Certified Associate (OCA) and have Khalid A Mughal & Rolf W Rasmussen on-line!
See this thread for details.
Win a copy of Programmer's Guide to Java SE 8 Oracle Certified Associate (OCA) this week in the OCAJP forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

how to find monday in a selected date

 
Rajendra Prakash
Ranch Hand
Posts: 293
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
when i select a date, i need to find sunday and monday for that particular week . can you give idea for this.
If you dont understand means, just consider am selecting a date. Then i have get start date and end date of a week

 
Matthew Brown
Bartender
Posts: 4568
9
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Well, it seems the first step is to get the day of the week for the date you're interested in. The Calendar class can do that - look at the get method and the DAY_OF_WEEK constant in the Javadocs.

Once you've got that, you can roll the date forward/back the right number of days. The Calendar.add method will do that for you.
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic