Article View: borland.public.jbuilder.java.language
Article #17493Re: Calendar help (Days of Month)
From: Peter McKeown
Date: Wed, 04 Nov 1998 00:00
Date: Wed, 04 Nov 1998 00:00
40 lines
1233 bytes
1233 bytes
Johan
I copied this from the sun tutorial, seems to work just fine.
public int daysInMonth(){
int month = frmTTable.StartDate.get(Calendar.MONTH)+1;
int year = frmTTable.StartDate.get(Calendar.YEAR);
int numDays;
switch (month) {
case 1:
case 3:
case 5:
case 7:
case 8:
case 10:
case 12:
numDays = 31;
break;
case 4:
case 6:
case 9:
case 11:
numDays = 30;
break;
case 2:
if ( ((year % 4 == 0) && !(year % 100 == 0)) || (year % 400
== 0) )
numDays = 29;
else
numDays = 28;
break;
default:
numDays = 0;
}
return numDays;
}
Regards
Peter
Technical Details
Message-ID:
<36405e1e.2636313@forums.borland.com>Path:
arc1-ca.pugleaf.net!unknown!not-for-mailReferences:
<01be03f0$3f3317e0$6bcc79c0@pc4107.stmf.se>Show Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: f74b3,3bd436b7dd5bc64c X-Google-Attributes: gidf74b3,public From: peterm@pop.onwe.co.za (Peter McKeown) Subject: Re: Calendar help (Days of Month) Date: 1998/11/04 Message-ID: <36405e1e.2636313@forums.borland.com> X-Deja-AN: 408296376 References: <01be03f0$3f3317e0$6bcc79c0@pc4107.stmf.se> Organization: Another Netscape Collabra Server User Newsgroups: borland.public.jbuilder.java.language