• 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:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

First day of the first week of the month

 
Greenhorn
Posts: 26
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hello,

I wanna know how can I determine the first day of the first week in any month.
For example the first day in JAN/2007 is the 2(Monday) cause it's the first day of the week, in that start a new Month...
I need your helps!!!

N�stor Alduey
SCJP 1.4
 
Ranch Hand
Posts: 2412
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I'm a little confused with your question. Do you mean what day of the month is the first Monday?

There are methods in the Calendar class that allow you to specify a month, year, day, etc.

From that you should be able to find on what day the first of the month is.
 
Marshal
Posts: 28193
95
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
You should really clarify what you want. It's hard to understand "the first day of the first week of a month". Let's take an example: May 2007.

The first week of May 2007 is... well, it depends if you start your weeks on Sunday or on Monday. Let's suppose Monday. Then the first week of May 2007 is the one starting on April 30 and ending on May 6. And the first day of that week is April 30.

This is all based on the standard way that Calendar defines those terms, and that in turn is based on standards published by the ISO. But is it what you want? It's quite common for people to have their own ideas of what things like "first week of a month" mean regardless of any international standards.

In fact it's quite common for people to miss the fact that the weeks don't fit into the months. I've had people ask for sales reports by week within month, and when I ask them what to do about the weeks that span month-end they haven't a clue what they really wanted.
 
Nestor Alduey
Greenhorn
Posts: 26
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
You that when a month start not is necesary that the month start's in the first day of the week. For that it could be that the april/01/2007 starts one monday or it could be that starts one webnesday or friday... I want a funtion that I give the month and the year and it give me the day that the month starts...
Thanks!!!
 
Keith Lynn
Ranch Hand
Posts: 2412
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Look at the API for Calendar.

In particular look at the get method and the set method.
 
Paul Clapham
Marshal
Posts: 28193
95
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Originally posted by Nestor Alduey:
I want a funtion that I give the month and the year and it give me the day that the month starts...

So in other words, you just want the first day of the month?
 
Nestor Alduey
Greenhorn
Posts: 26
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
The day of the week when starts the month...
 
Paul Clapham
Marshal
Posts: 28193
95
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Originally posted by Nestor Alduey:
The day of the week when starts the month...

Okay. So given May 2007, you want to know that the first day of that month is a Tuesday, for example?
 
Ranch Hand
Posts: 1179
Mac OS X Eclipse IDE
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

The day of the week when starts the month...


Originally posted by Nestor Alduey:
Hello,

I wanna know how can I determine the first day of the first week in any month.
For example the first day in JAN/2007 is the 2(Monday) cause it's the first day of the week, in that start a new Month...
I need your helps!!!

N�stor Alduey
SCJP 1.4



I don't understand why you then want that JAN/2007 should start on the first day of the week in this Month? - depends if you start your weeks on Sunday or on Monday.
[ April 14, 2007: Message edited by: Rene Larsen ]
 
Greenhorn
Posts: 25
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
This should do what you need


 
I will suppress my every urge. But not this shameless plug:
a bit of art, as a gift, that will fit in a stocking
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic