Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.java.programmer > #13524 > unrolled thread

Getting the Week count for the Two date range

Started byGeorge <vijuitech@gmail.com>
First post2012-04-13 08:04 -0700
Last post2012-05-05 19:58 -0400
Articles 8 — 5 participants

Back to article view | Back to comp.lang.java.programmer


Contents

  Getting the Week count for the Two date range George <vijuitech@gmail.com> - 2012-04-13 08:04 -0700
    Re: Getting the Week count for the Two date range fred.l.kleinschmidt@gmail.com - 2012-04-13 08:14 -0700
      Re: Getting the Week count for the Two date range Lew <lewbloch@gmail.com> - 2012-04-13 11:10 -0700
      Re: Getting the Week count for the Two date range George <vijuitech@gmail.com> - 2012-04-14 03:29 -0700
    Re: Getting the Week count for the Two date range Roedy Green <see_website@mindprod.com.invalid> - 2012-04-14 06:49 -0700
      Re: Getting the Week count for the Two date range George <vijuitech@gmail.com> - 2012-04-15 21:00 -0700
    Re: Getting the Week count for the Two date range Roedy Green <see_website@mindprod.com.invalid> - 2012-04-29 07:49 -0700
      Re: Getting the Week count for the Two date range Arne Vajhøj <arne@vajhoej.dk> - 2012-05-05 19:58 -0400

#13524 — Getting the Week count for the Two date range

FromGeorge <vijuitech@gmail.com>
Date2012-04-13 08:04 -0700
SubjectGetting the Week count for the Two date range
Message-ID<4dda83fc-0bdf-4039-a70c-90b671996e18@gh10g2000pbc.googlegroups.com>
Hi,
       I am using a date application. Here I am giving a date as input
and the total week count is the output.The week count should be
calculated from Sunday to Saturday as one week count. Is there any
method in java to get this format of  week count.

Cheers!

George

[toc] | [next] | [standalone]


#13525

Fromfred.l.kleinschmidt@gmail.com
Date2012-04-13 08:14 -0700
Message-ID<13575403.14.1334330054189.JavaMail.geo-discussion-forums@pbrh4>
In reply to#13524
On Friday, April 13, 2012 8:04:08 AM UTC-7, George wrote:
> Hi,
>        I am using a date application. Here I am giving a date as input
> and the total week count is the output.The week count should be
> calculated from Sunday to Saturday as one week count. Is there any
> method in java to get this format of  week count.
> 

Not enough information.
Suppose d1 is a Monday, and d2 is Friday 11 days later. What is the "week count" of this range?

[toc] | [prev] | [next] | [standalone]


#13529

FromLew <lewbloch@gmail.com>
Date2012-04-13 11:10 -0700
Message-ID<33458187.121.1334340619743.JavaMail.geo-discussion-forums@pbts20>
In reply to#13525
fred.l.kl...@ wrote:
> George wrote:
>> Hi,
>>        I am using a date application. Here I am giving a date as input
>> and the total week count is the output.The week count should be
>> calculated from Sunday to Saturday as one week count. Is there any
>> method in java to get this format of  week count.
>> 
> 
> Not enough information.
> Suppose d1 is a Monday, and d2 is Friday 11 days later. What is the "week count" of this range?

Once you have your spec down more precisely, look perhaps to the 'java.util.Calendar' class for ways to implement it. It will require piecemeal assembly of the exact algorithm you want, using things like
<http://docs.oracle.com/javase/7/docs/api/java/util/Calendar.html#get(int)>
<http://docs.oracle.com/javase/7/docs/api/java/util/Calendar.html#WEEK_OF_YEAR>
<http://docs.oracle.com/javase/7/docs/api/java/util/Calendar.html#add(int, int)>
<http://docs.oracle.com/javase/7/docs/api/java/util/Calendar.html#setFirstDayOfWeek(int)>
<http://docs.oracle.com/javase/7/docs/api/java/util/Calendar.html#setMinimalDaysInFirstWeek(int)>
etc.

If all that is too primitive, the Joda Time initiative is very promising:

<http://joda-time.sourceforge.net/>

-- 
Lew

[toc] | [prev] | [next] | [standalone]


#13545

FromGeorge <vijuitech@gmail.com>
Date2012-04-14 03:29 -0700
Message-ID<724c4d2f-4bc7-4ca2-961a-820b7e7481b6@lf20g2000pbb.googlegroups.com>
In reply to#13525
On Apr 13, 8:14 pm, fred.l.kleinschm...@gmail.com wrote:
> On Friday, April 13, 2012 8:04:08 AM UTC-7, George wrote:
> > Hi,
> >        I am using a date application. Here I am giving a date as input
> > and the total week count is the output.The week count should be
> > calculated from Sunday to Saturday as one week count. Is there any
> > method in java to get this format of  week count.
>
> Not enough information.
> Suppose d1 is a Monday, and d2 is Friday 11 days later. What is the "week count" of this range?

the week count is 2

monday to saturday as 1 week count and sunday to friday another week
count.

In my case week count should start from Sunday to Saturday.

[toc] | [prev] | [next] | [standalone]


#13546

FromRoedy Green <see_website@mindprod.com.invalid>
Date2012-04-14 06:49 -0700
Message-ID<g00jo71cn3ogu5bfq1necv1h9vp11j51s4@4ax.com>
In reply to#13524
On Fri, 13 Apr 2012 08:04:08 -0700 (PDT), George <vijuitech@gmail.com>
wrote, quoted or indirectly quoted someone who said :

>       I am using a date application. Here I am giving a date as input
>and the total week count is the output.The week count should be
>calculated from Sunday to Saturday as one week count. Is there any
>method in java to get this format of  week count.

the trick will be getting a day number since 1970, and dividing by 7
and taking a modus 7. 

There are various ways to calculate it.  One might be  subtract the
two day numbers and divide by 7, or add 6 first and divide by 7 for a
covered quotient.
-- 
Roedy Green Canadian Mind Products
http://mindprod.com
When you were a child, if you did your own experiment
to see if it was better to put to cocoa into your cup first
or the hot milk first, then you likely have the programmer gene..

[toc] | [prev] | [next] | [standalone]


#13571

FromGeorge <vijuitech@gmail.com>
Date2012-04-15 21:00 -0700
Message-ID<8e10cb28-f624-47fe-a1d2-cbf1b5be6bf3@8g2000pbm.googlegroups.com>
In reply to#13546
On Apr 14, 6:49 pm, Roedy Green <see_webs...@mindprod.com.invalid>
wrote:
> On Fri, 13 Apr 2012 08:04:08 -0700 (PDT), George <vijuit...@gmail.com>
> wrote, quoted or indirectly quoted someone who said :
>
> >       I am using a date application. Here I am giving a date as input
> >and the total week count is the output.The week count should be
> >calculated from Sunday to Saturday as one week count. Is there any
> >method in java to get this format of  week count.
>
> the trick will be getting a day number since 1970, and dividing by 7
> and taking a modus 7.
>
> There are various ways to calculate it.  One might be  subtract the
> two day numbers and divide by 7, or add 6 first and divide by 7 for a
> covered quotient.
> --
> Roedy Green Canadian Mind Productshttp://mindprod.com
> When you were a child, if you did your own experiment
> to see if it was better to put to cocoa into your cup first
> or the hot milk first, then you likely have the programmer gene..

Thank You!

Cheers!

George

[toc] | [prev] | [next] | [standalone]


#14028

FromRoedy Green <see_website@mindprod.com.invalid>
Date2012-04-29 07:49 -0700
Message-ID<n5lqp7tgudfpks98g65cnn6d9euv66tjmu@4ax.com>
In reply to#13524
On Fri, 13 Apr 2012 08:04:08 -0700 (PDT), George <vijuitech@gmail.com>
wrote, quoted or indirectly quoted someone who said :

>       I am using a date application. Here I am giving a date as input
>and the total week count is the output.The week count should be
>calculated from Sunday to Saturday as one week count. Is there any
>method in java to get this format of  week count.

There are so many ways of computing such things, what you really want
is a sequential day number. Then you do some subtractions and modular
% and /.  To get the day number, see
http://mindprod.com/products1.htm#BIGDATE
-- 
Roedy Green Canadian Mind Products
http://mindprod.com
Programmers love to create simplified replacements for HTML. 
They forget that the simplest language is the one you 
already know. They also forget that their simple little 
markup language will bit by bit become even more convoluted 
and complicated than HTML because of the unplanned way it grows.
.

[toc] | [prev] | [next] | [standalone]


#14309

FromArne Vajhøj <arne@vajhoej.dk>
Date2012-05-05 19:58 -0400
Message-ID<4fa5bec5$0$284$14726298@news.sunsite.dk>
In reply to#14028
On 4/29/2012 10:49 AM, Roedy Green wrote:
> On Fri, 13 Apr 2012 08:04:08 -0700 (PDT), George<vijuitech@gmail.com>
> wrote, quoted or indirectly quoted someone who said :
>>        I am using a date application. Here I am giving a date as input
>> and the total week count is the output.The week count should be
>> calculated from Sunday to Saturday as one week count. Is there any
>> method in java to get this format of  week count.
>
> There are so many ways of computing such things, what you really want
> is a sequential day number. Then you do some subtractions and modular
> % and /.  To get the day number, see
> http://mindprod.com/products1.htm#BIGDATE

Or simpler - just use what comes with Java.

Arne

[toc] | [prev] | [standalone]


Back to top | Article view | comp.lang.java.programmer


csiph-web