又是循环。。。 大家来帮帮忙 怎么用JAVA实现: 输入一个随机的日期,可以得到这年是平年还是闰年,并且还要算出离当年的1月1日有多少天。这还得考虑每个月的天数怎么弄啊??帮帮忙啊 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 我的那个答复不行吗?如何判断闰年 1。能被4整除而不能被100整除。 2。能被400整除。 if ((year%4 == 0) && (year%100 != 0) && (year%400 == 0))至于如何计算差多少天 看看我的这个帖子吧: http://blog.csdn.net/justinavril/archive/2008/09/06/2891266.aspx public class CalendarTester { static Calendar cal = Calendar.getInstance(); public static boolean isLeapYear(Date date) { cal.setTime(date); return (cal.get(Calendar.YEAR) % 4 == 0) || (cal.get(Calendar.YEAR) % 400 == 0); } public static int countDays(Date date) { cal.setTime(date); return cal.get(Calendar.DAY_OF_YEAR); } public static void main(String[] args) { Date now = new Date(); System.out.println("IsLeapYear : " + isLeapYear(now)); System.out.println("total day : " + countDays(now)); }} public static boolean isLeapYear(Date date) { cal.setTime(date); return (cal.get(Calendar.YEAR) % 4 == 0 && cal.get(Calendar.YEAR) % 100 != 0) || (cal.get(Calendar.YEAR) % 400 == 0); } 为什么127+1是等于-128 File类的一个问题 新手求助:jPanel绘图问题 跪求各位帮忙!谢谢你们了! 请问有java中文帮助吗? 关于文件编码的问题,谢谢大家了。 java源代码介绍几个好点的网站下载啊,主要用于学习,小例子小程序。 提问 c# 中的 XmlTextWriter 相当于java里的那个类 ????(在线等) 谁有详细的RMI资料(比如具体的:套接字工厂,动态加载对象等),拿出来,给分200,现在先放100分(中,英文均可,要详细,sun的除外(看 大家救我啊! hibernate查询问题 关于两个简单的正则表达式问题
1。能被4整除而不能被100整除。
2。能被400整除。
if ((year%4 == 0) && (year%100 != 0) && (year%400 == 0))
至于如何计算差多少天 看看我的这个帖子吧:
http://blog.csdn.net/justinavril/archive/2008/09/06/2891266.aspx
static Calendar cal = Calendar.getInstance(); public static boolean isLeapYear(Date date) {
cal.setTime(date);
return (cal.get(Calendar.YEAR) % 4 == 0)
|| (cal.get(Calendar.YEAR) % 400 == 0);
} public static int countDays(Date date) {
cal.setTime(date);
return cal.get(Calendar.DAY_OF_YEAR);
} public static void main(String[] args) {
Date now = new Date();
System.out.println("IsLeapYear : " + isLeapYear(now));
System.out.println("total day : " + countDays(now));
}
}
cal.setTime(date);
return (cal.get(Calendar.YEAR) % 4 == 0 && cal.get(Calendar.YEAR) % 100 != 0)
|| (cal.get(Calendar.YEAR) % 400 == 0);
}