import java.util.Calendar;
import java.util.GregorianCalendar;
/**
* CalTest.java
*
* Version 0.1
*
* Created 2006-6-9 16:29:22
*
* TODO
*/
public class CalTest
{
/**
* 得到本月的最后一天;
* @return
*/
public static int getLastDayOfMonth(){
int intDay = 0;
GregorianCalendar cca = new GregorianCalendar();
Calendar ca = cca.getInstance();
intDay = cca.getActualMaximum(ca.DAY_OF_MONTH);
return intDay;
}
}
/**
-----------------------下面是测试类-------------------------
**/
import junit.framework.TestCase;
public class CalTestTest extends TestCase
{
protected void setUp() throws Exception
{
super.setUp();
}
protected void tearDown() throws Exception
{
super.tearDown();
}
/*
* Test method for 'CalTest.getLastDayOfMonth()'
*/
public void testGetLastDayOfMonth()
{
int intDay = CalTest.getLastDayOfMonth();
System.out.println(intDay);
}
}
posted on 2006-06-09 16:51
梦源 阅读(526)
评论(0) 编辑 收藏