ÈÕÆÚÀà¼Ó¼õ¼°JavaÖÐÈÕÆÚÀà²Ù×÷Ëã·¨´óÈ«
1.¼ÆËãijһÔ·ݵÄ×î´óÌìÊý
1Calendar time=Calendar.getInstance();
2time.clear();
3time.set(Calendar.YEAR,year); //year Ϊ int
4time.set(Calendar.MONTH,i-1);//×¢Òâ,Calendar¶ÔÏóĬÈÏÒ»ÔÂΪ0
5int day=time.getActualMaximum(Calendar.DAY_OF_MONTH);//±¾Ô·ݵÄÌìÊý
×¢£ºÔÚʹÓÃset·½·¨Ö®Ç°£¬±ØÐëÏÈclearһϣ¬·ñÔòºÜ¶àÐÅÏ¢»á¼Ì³Ð×Ôϵͳµ±Ç°Ê±¼ä
2.CalendarºÍDateµÄת»¯
(1) Calendarת»¯ÎªDate
Calendar cal=Calendar.getInstance();
Date date=cal.getTime();
(2) Dateת»¯ÎªCalendar
Date date=new Date();
Calendar cal=Calendar.getInstance();
cal.setTime(date);
3.¸ñʽ»¯Êä³öÈÕÆÚʱ¼ä £¨Õâ¸öÓõıȽ϶ࣩ
ÆäÒ»
Date date=new Date();
SimpleDateFormat df=new SimpleDateFormat("yyyy-MM-dd hh:mm:ss");
String time=df.format(date);
System.out.println(time);//2008-10-27 08:52:32
Æä¶þ
Calendar c = Calendar.getInstance();
System.out.println(c.getTime());//Mon Oct 27 08:51:21 CST 2008
SimpleDateFormat simpleDateTimeFormat = new SimpleDateFormat(" yyyy-MM-dd HH:mm:ss ");
c = Calendar.getInstance(Locale.CHINESE);
System.out.println(simpleDateTimeFormat.format(c.getTime()));// 2008-10-27 08:51:21
4.¼ÆËãÒ»ÄêÖеĵڼ¸ÐÇÆÚ
(1)¼ÆËãijһÌìÊÇÒ»ÄêÖеĵڼ¸ÐÇÆÚ
Calendar cal=Calendar.getInstance();
cal.set(Calendar.YEAR, 2006);
cal.set(Calendar.MONTH, 8);
cal.set(Calendar.DAY_OF_MONTH, 3);
int weekno=cal.get(Calendar.WEEK_OF_YEAR);
(2)¼ÆËãÒ»ÄêÖеĵڼ¸ÐÇÆÚÊǼ¸ºÅ
SimpleDateFormat df=new SimpleDateFormat("yyyy-MM-dd");
Calendar cal=Calendar.getInstance();
cal.set(Calendar.YEAR, 2006);
cal.set(Calendar.WEEK_OF_YEAR, 1);
cal.set(Calendar.DAY_OF_WEEK, Calendar.MONDAY);
System.out.println(df.format(cal.getTime()));
Êä³ö:
2006-01-02
5.add()ºÍroll()µÄÓ÷¨(²»Ì«³£ÓÃ)
(1)add()·½·¨
SimpleDateFormat df=new SimpleDateFormat("yyyy-MM-dd");
Calendar cal=Calendar.getInstance();
cal.set(Calendar.YEAR, 2006);
cal.set(Calendar.MONTH, 8);
cal.set(Calendar.DAY_OF_MONTH, 3);
cal.add(Calendar.DATE, -4);
Date date=cal.getTime();
System.out.println(df.format(date));
cal.add(Ca
Ïà¹ØÎĵµ£º
String ×Ö·û´®³£Á¿
StringBuffer ×Ö·û´®±äÁ¿£¨Ḭ̈߳²È«£©
StringBuilder ×Ö·û´®±äÁ¿£¨·ÇḬ̈߳²È«£©
¼òÒªµÄ˵£¬ String ÀàÐÍºÍ StringBuffer ÀàÐ͵ÄÖ÷ÒªÐÔÄÜÇø±ðÆäʵÔÚÓÚ String ÊDz»¿É±äµÄ¶ÔÏó, Òò´ËÔÚÿ´Î¶Ô String ÀàÐͽøÐиıäµÄʱºòÆäʵ¶¼µÈͬÓÚÉú³ÉÁËÒ»¸öÐ嵀 String ¶ÔÏó£¬È»ºó½«Ö¸ÕëÖ¸ÏòÐ嵀 String ¶ÔÏó£¬ËùÒÔ¾ ......
Monkey_peach´úÂë
package com.sailor.game;
/**
* ÌâÄ¿£ººï×Ó³ÔÌÒÎÊÌ⣺ºï×ÓµÚÒ»ÌìÕªÏÂÈô¸É¸öÌÒ×Ó£¬µ±¼´³ÔÁËÒ»°ë£¬»¹²»ñ«£¬ÓÖ¶à³ÔÁËÒ»¸ö µÚ¶þÌìÔçÉÏÓÖ½«Ê£
* ϵÄÌÒ×Ó³ÔµôÒ»°ë£¬ÓÖ¶à³ÔÁËÒ»¸ö¡£ÒÔºóÿÌìÔçÉ϶¼³ÔÁËÇ°Ò»ÌìʣϠ......
Ëü¿ÉÒÔµ¼Èë¿â£¬µ÷ÓÃÍâÃæµÄ¿âº¯Êý£¬javaÓïÑԾͺܺõĵØÀûÓÃÁËÕâÒ»µã£¬jspÒ²¿ÉÒÔÔÚÍøÒ³Öе÷ÓÃjava±àдºÃµÄ³ÌÐò£¬ÒªÊ¹ÓÃjavabean±êÇ©
struts±¾Éí¾ÍÊǶÔjava¼¼ÊõÒ»¸ö°ü×°,°üÀ¨£¬html,jsp¼°±êÇ©,servlet¡£
hibernateÊDZðÈ˱àдºÃÓ³ÉäÊý¾Ý¿âµÄ¹¤¾ß£¬Æä´úÂ붼ÊÇÓÃjavaÓïÑÔ±àдµÄ£¬Ö»ÊÇΪÁË·½±ãÓû§Ê¹Óã¬Óû§Ö»Òªµ¼ÈëÆä¿â£¬µ÷ÓÃÆ ......
package com.jcauto.action;
import java.util.ArrayList;
import java.util.List;
public class ContentRsp {
private String resultCode;
List<ContentInfo> contentList = new ArrayList<ContentInfo>();
public void addContent(ContentInfo contentInfo) {
contentList.add(contentI ......