Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsWhite Papers
Discussion GroupsFirst AidDatabasesJavaBeansGUIJava 3DVirtual MachineCORBASecurityToolsGeneral
Java DirectoryOpen Source ProjectsSample Book ChaptersUser GroupsWeb Resources
Related Topics
Databases.NETMore Topics ...

Java Forum / General / August 2007

Tip: Looking for answers? Try searching our database.

How to know the date is first,second,third weeks...

Thread view: 
weetat - 13 Aug 2007 04:51 GMT
Hi all,

 I have column in the database , release_date . The release_date
column is to capture when the data are first released to our client.

 Our client want us to check if for example the release_date is 9
August 2007 is on the first week of the month. However it did not the
referred to month but to release_date.

  for example :

    Prod      reelase_date

      A

Thanks

wee tat
Sherm Pendley - 13 Aug 2007 05:16 GMT
>   Our client want us to check if for example the release_date is 9
> August 2007 is on the first week of the month. However it did not the
> referred to month but to release_date.

Have a look at the java.util.Calendar class. For example:

   import java.io.*;
   import java.util.Calendar;

   public class CalendarExample {

       public static void main (String argv[]) {
           Calendar cal = Calendar.getInstance();
           cal.set(2007, 8, 9); /* year, month, day */
           System.out.println("Week of Month: " +
                   cal.get(Calendar.WEEK_OF_MONTH));
       }

   }

sherm--

Signature

Web Hosting by West Virginians, for West Virginians: http://wv-www.net
Cocoa programming in Perl: http://camelbones.sourceforge.net

Lew - 13 Aug 2007 11:22 GMT
>>   Our client want us to check if for example the release_date is 9
>> August 2007 is on the first week of the month. However it did not the
[quoted text clipped - 15 lines]
>
>     }

Another approach, useful if you have to characterize dates more fully as, for
example, weekday vs. weekend, holidays (perhaps with separate logic for
holidays in different countries), "A" days vs. "B" days or other attributes
not known to java.util.Calendar, is to use a database table of dates.  Each
date is tagged with the attributes of interest.  Then all you have to do is
SELECT from that table to find out if a given date is a weekend, holiday or
whatever.  It also supports queries like "how many non-holiday days are in an
interval, after the first four?"

Signature

Lew

Dr J R Stockton - 14 Aug 2007 14:21 GMT
In comp.lang.java.programmer message <1186977085.227438.92670@q3g2000prf
.googlegroups.com>, Sun, 12 Aug 2007 20:51:25, weetat
<weetat.yeo@gmail.com> posted:

>  Our client want us to check if for example the release_date is 9
>August 2007 is on the first week of the month.

If that means in the first seven days, check that day-of-month is less
that 8.

Otherwise, you need to say what definition of week you are using -
International Standard, US vernacular, etc.

Signature

(c) John Stockton, Surrey, UK.  ?@merlyn.demon.co.uk   Turnpike v6.05   IE 6.
Web  <URL:http://www.merlyn.demon.co.uk/> - w. FAQish topics, links, acronyms
PAS EXE etc : <URL:http://www.merlyn.demon.co.uk/programs/> - see 00index.htm
Dates - miscdate.htm moredate.htm js-dates.htm pas-time.htm critdate.htm etc.



Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.