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


Groups > comp.lang.java.programmer > #13529

Re: Getting the Week count for the Two date range

From Lew <lewbloch@gmail.com>
Newsgroups comp.lang.java.programmer
Subject Re: Getting the Week count for the Two date range
Date 2012-04-13 11:10 -0700
Organization http://groups.google.com
Message-ID <33458187.121.1334340619743.JavaMail.geo-discussion-forums@pbts20> (permalink)
References <4dda83fc-0bdf-4039-a70c-90b671996e18@gh10g2000pbc.googlegroups.com> <13575403.14.1334330054189.JavaMail.geo-discussion-forums@pbrh4>

Show all headers | View raw


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

Back to comp.lang.java.programmer | Previous | NextPrevious in thread | Next in thread | Find similar | Unroll thread


Thread

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

csiph-web