java中根据系统时间动态获取季度以及月份 /*** 根据系统的时间,来判断是否在每月16日-下月15日期之间,并且显示上一月的时间 * 例如,2012年8月16日-2012年9月15日期间,就显示2012年3季度7月 */ 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 public static void main(String[] args) throws Exception { SimpleDateFormat sdf = new SimpleDateFormat("yyyy年MM月dd日"); Calendar now = Calendar.getInstance(); System.out.println(sdf.format(now.getTime())); Calendar time1 = new GregorianCalendar(now.get(Calendar.YEAR), now.get(Calendar.MONTH), 16); System.out.println(sdf.format(time1.getTime())); Calendar time2 = new GregorianCalendar(now.get(Calendar.YEAR), now.get(Calendar.MONTH) + 1, 15); System.out.println(sdf.format(time2.getTime())); if (now.after(time1) && now.before(time2)) { now.add(Calendar.MONTH, -1); } else { now.add(Calendar.MONTH, -2); } System.out.println("-----------------------"); System.out.println(sdf.format(now.getTime())); System.out.println(now.get(Calendar.MONTH)); System.out.println(now.get(Calendar.YEAR)); int month = now.get(Calendar.MONTH) + 1; if(month == 1 || month ==2 || month ==3){ System.out.println("一季度"); } else if(month == 4 || month ==5 || month ==6){ System.out.println("二季度"); } else if(month == 7 || month ==8 || month ==9){ System.out.println("三季度"); } else if(month == 10 || month ==11 || month ==12){ System.out.println("四季度"); } } hibernate不去映射mysql字段? 超时后session没有清空 java向c传递一个结构 ??? 请教各位(学习j2ee的过程中要做哪些项目来提高学习效率) Spring 注入的问题 google google 关于tomcat的文档。 那位朋友给个weblogic 6.1的下载地址好吗? 部署示例应用出错,求解! 关于一个mysql的语法问题,别看那么多代码,只要看与数据库有关的就行 JAVA怎么才能实现这样的统计图,希望大家给点建议!
System.out.println(sdf.format(now.getTime()));
Calendar time1 = new GregorianCalendar(now.get(Calendar.YEAR), now.get(Calendar.MONTH), 16); System.out.println(sdf.format(time1.getTime()));
Calendar time2 = new GregorianCalendar(now.get(Calendar.YEAR), now.get(Calendar.MONTH) + 1, 15);
System.out.println(sdf.format(time2.getTime())); if (now.after(time1) && now.before(time2)) {
now.add(Calendar.MONTH, -1);
} else {
now.add(Calendar.MONTH, -2);
}
System.out.println("-----------------------");
System.out.println(sdf.format(now.getTime()));
System.out.println(now.get(Calendar.MONTH));
System.out.println(now.get(Calendar.YEAR));
int month = now.get(Calendar.MONTH) + 1;
if(month == 1 || month ==2 || month ==3){
System.out.println("一季度");
}
else if(month == 4 || month ==5 || month ==6){
System.out.println("二季度");
}
else if(month == 7 || month ==8 || month ==9){
System.out.println("三季度");
}
else if(month == 10 || month ==11 || month ==12){
System.out.println("四季度");
}
}