Win a copy of Rust Web Development this week in the Other Languages forum!
  • Post Reply 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:
  • Tim Cooke
  • Campbell Ritchie
  • Ron McLeod
  • Liutauras Vilda
  • Jeanne Boyarsky
Sheriffs:
  • Junilu Lacar
  • Rob Spoor
  • Paul Clapham
Saloon Keepers:
  • Tim Holloway
  • Tim Moores
  • Jesse Silverman
  • Stephan van Hulst
  • Carey Brown
Bartenders:
  • Al Hobbs
  • Piet Souris
  • Frits Walraven

How display the weeks of the month?

 
Greenhorn
Posts: 9
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Guys,
I'm trying to calculate the weeks of the month but I'm very confused how can I do... (I'm using JodaTime)

I considered, for example, current month (variable in input):



I would like see in output this result (based on Local date, possibly):

1 week: 03-30-2014 --- 04-05-2014
2 week: 04-06-2014 --- 04-12-2014
3 week: 04-13-2014 --- 04-19-2014
4 week: 04-20-2014 --- 04-26-2014
5 week: 04-27-2014 --- 05-03-2014

How can I do?? :-S

Thanks!!!
 
Greenhorn
Posts: 6
1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hmm... since this doesn't provide too much info like code, I'll provide some hints to allow you to build it up.

You can try to take a look at this page: http://joda-time.sourceforge.net/userguide.html

for your formatted output I would look specifically at the Freaky Formatter section

for your local time look at the Changing Time Zone section for example to get the local date just:

// get current moment in default time zone
DateTime dt = new DateTime();

which is going to give you all this:
The DateTime implementation provides a complete list of standard calendar fields:
dt.getEra();
dt.getYear();
dt.getWeekyear();
dt.getCenturyOfEra();
dt.getYearOfEra();
dt.getYearOfCentury();
dt.getMonthOfYear();
dt.getWeekOfWeekyear();
dt.getDayOfYear();
dt.getDayOfMonth();
dt.getDayOfWeek();
 
Roberto Tucci
Greenhorn
Posts: 9
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks for reply!
I've fixed my problem as is:



Thanks!!
 
You showed up just in time for the waffles! And this tiny ad:
Building a Better World in your Backyard by Paul Wheaton and Shawn Klassen-Koop
https://coderanch.com/wiki/718759/books/Building-World-Backyard-Paul-Wheaton
reply
    Bookmark Topic Watch Topic
  • New Topic