import java.text.*;
import java.util.Calendar;
public class VeDate {
/**
* »ñÈ¡ÏÖÔÚʱ¼ä
*
* @return ·µ»Øʱ¼äÀàÐÍ yyyy-MM-dd HH:mm:ss
*/
public static Date getNowDate() {
Date currentTime = new Date();
SimpleDateFormat formatter = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
String dateString = formatter.format(currentTime);
ParsePosition pos = new ParsePosition(8);
Date currentTime_2 = formatter.parse(dateString, pos);
return currentTime_2;
}
/**
* »ñÈ¡ÏÖÔÚʱ¼ä
*
* @return·µ»Ø¶Ìʱ¼ä¸ñʽ yyyy-MM-dd
*/
public static Date getNowDateShort() {
Date currentTime = new Date();
SimpleDateFormat formatter = new SimpleDateFormat("yyyy-MM-dd");
String dateString = formatter.format(currentTime);
ParsePosition pos = new ParsePosition(8);
&nbs ......
ÓÉÓÚ Source Insight µÄ´úÂëÒ׶ÁµÄÓÅÔ½ÐÔÄÜ,£¬Ê¹Óà Source Insight ±à¼ Java ´úÂëÊÇÒ»¸ö²»´íµÄÑ¡Ôñ£¬µ±È»Ëü²»ÄÜÓëרҵµÄ Eclipse ¼° Netbeans ÕâÑùµÄIDE Ïà±È£»
±¾ÈËʹÓÃËüÊÇÒòΪ Source Insight µÄÌå»ý±È½ÏС£¬¿ÉÒÔ×Ô¶¨ÒåÉèÖÃÓû§ÃüÁÓÃÆðÀ´Ò²ËãÊǵÃÐÄÓ¦ÊÖÁË¡£
ÏÂÃæ½éÉÜһϱ¾ÈË×ܽáµÄÒ»µã¹ØÓÚ±àÒëºÍÖ´ÐÐJava³ÌÐòÈÎÎñ¶Ô Source Insight Óû§×Ô¶¨ÒåÃüÁîµÄÉèÖ÷½·¨¡£
´´½¨±àÒë Java Ô´³ÌÐòµÄ Óû§×Ô¶¨ÒåÃüÁî
¡ñ Ê×ÏÈÔÚÓ²ÅÌÖд´½¨Ò»¸ö Java ³ÌÐò±àÒëºÍÖ´ÐеÄÖ¸¶¨Â·¾¶£¬ÎÒÕâÀï´´½¨µÄÊÇ D:\My Documents\Source Insight\JavaPorjects
Õâ¸öĿ¼ÊÇÖ÷Òª·ÅÖà Java Ô´Îļþ£¬ÔÚÕâ¸öĿ¼ÏÂÎÒÓÖ´´½¨ÁËÒ»¸ö sourcefiles.list Îļþ£¬´´½¨Õâ¸öÎļþµÄÄ¿µÄÊÇΪÁ˺óÃæ±àÒë Java ³ÌÐòʱÐèÒªÓÃËü¡£
¡ñ ÔÙÉÏÃæ´´½¨µÄĿ¼ÏÂÔÙ´´½¨Ò»¸ö Classes ×ÓĿ¼£¬¸ÃĿ¼ÊÇΪÁË·ÅÖñàÒëºóµÄ Java ×Ö½ÚÂëÎļþ£»Í¬Ê±ÔÚÕâ¸öĿ¼Ï´´½¨Ò»¸ö¿ÕµÄÅú´¦ÀíÎļþ ClassStart.bat £¬ÔÚÏÂÃæµÄ²½¾ÛÖ ......
ºÃ¾Ã²»¸üÐÂÁË£¬ÄÃÒÔÇ°µÄÎÄÕ´մÕÊý£¬´ÓjavaÄDZßתһƪ¹ýÀ´¡£
×î½ü·¢ÏÖÒ»±¾<javaÓëģʽ>,ÕýºÃÔÙιÊһϵ±ÄêµÄרҵ¿ÎÄÚÈÝ,ÏÂÃæÊÇÕ⼸Ìì¼ÇµÄ±Ê¼Ç.(²¢²»ÊÇϵͳµÄ½²½âÊéÖеÄÄÚÈÝ)
Ò» ×ÛÊö:
1¡¢²»ÒªÊ¹Óýӿڶ¨Òå³£Á¿
2¡¢×Ô¼ºÉÙÓñêÖ¾½Ó¿Ú
3¡¢²»Òª¼Ì³Ð¾ßÌåÀà
4¡¢Àà²ã´ÎµÄÖмä½ÚµãÓ¦¸ÃÊǽӿڻòÕß³éÏóÀ࣬Ҷ×ÓÊǾßÌåÀà
5¡¢×ÓÀàÓ¦µ±À©Õ¹¸¸ÀàµÄÔðÈΣ¬¶ø²»ÊǸ²Ð´¸¸ÀàµÄÔðÈÎ
6¡¢ÃæÏò½Ó¿Ú±à³Ì
7¡¢²»ÒªÀÄÓü̳У¬×éºÏÓÅÏÈÓڼ̳Ð
javaÖÐÉè¼Æ²»µ±µÄÀࣺcalendar:×÷Ϊ½Ó¿Ú£¬º¬ÓÐÓë¾ßÌåµÄÀú·¨£¨ÂÞÂíÀú·¨£©Ïà¹ØµÄ³£Á¿£¬²»ÄÜÀ©Õ¹µ½ÖйúµÄÒõÀúÀú·¨£¨²»·ûºÏ¿ª±ÕÔÔò£©
properiesÀࣺÀÄÓü̳У¬¼Ì³ÐÖÁhashtable£¬Ó¦µ±Ê¹ÓþۺÏ
8¡¢µÑ±ÈÌØ·¨Ôò£ºÖ»Óë×Ô¼ºµÄÖ±½ÓÅóÓÑͨÐÅ£¬²»ÓëÄ°ÉúÈËͨÐÅ£¨1£©ÏÁÒåµÑ±ÈÌØ·¨Ôò£ºÖ»ÓëÅóÓÑͨѶ£¬Í¨¹ý×Ô¼ºµÄÅóÓÑ´«µÝ¼ä½ÓµÄµ÷Óã¨2£©½áºÏÒÀÀµµ¹×ªÔÔòÐ޸ģº²»±Øͨ¹ýÅóÓÑ´«µÝ¼ä½ÓµÄµ÷Óã¬Í¨¹ýÄ°ÉúÈ˵ijéÏó½Ó¿Úµ÷ÓÃÄ°ÉúÈ˵ÄÐÐΪ£¨ÒÀ¾É²»ÄÜÓë¾ßÌåµÄÄ°ÉúÈË·¢ÉúͨÐÅ£©
9¡¢¾¡Á¿½µµÍÀàÖгÉÔ±µÄ·ÃÎÊȨÏÞ£¬²»ÒªÉè¼ÆÍË»¯ÀࣨÀàËÆcÖÐstruc ......
¡¡¡¡Í¨¹ýÓÃstaticÀ´¶¨Òå·½·¨»ò³ÉÔ±£¬ÎªÎÒÃDZà³ÌÌṩÁËijÖÖ±ãÀû£¬´ÓijÖ̶ֳÈÉÏ¿ÉÒÔ˵ËüÀàËÆÓÚCÓïÑÔÖеÄÈ«¾Öº¯ÊýºÍÈ«¾Ö±äÁ¿¡£µ«ÊÇ£¬²¢²»ÊÇ˵ÓÐÁËÕâÖÖ
±ãÀû£¬Äã±ã¿ÉÒÔË洦ʹÓã¬Èç¹ûÄÇÑùµÄ»°£¬Äã±ãÐèÒªÈÏÕ濼ÂÇÒ»ÏÂ×Ô¼ºÊÇ·ñÔÚÓÃÃæÏò¶ÔÏóµÄ˼Ïë±à³Ì£¬×Ô¼ºµÄ³ÌÐòÊÇ·ñÊÇÃæÏò¶ÔÏóµÄ¡£ºÃÁË£¬ÏÖÔÚ¿ªÊ¼ÌÖÂÛ
this&superÕâÁ½¸ö¹Ø¼ü×ÖµÄÒâÒåºÍÓ÷¨¡£
¡¡¡¡ÔÚJavaÖУ¬thisͨ³£Ö¸µ±Ç°¶ÔÏó£¬superÔòÖ¸¸¸ÀàµÄ¡£µ±ÄãÏëÒªÒý
Óõ±Ç°¶ÔÏóµÄijÖÖ¶«Î÷£¬±ÈÈ統ǰ¶ÔÏóµÄij¸ö·½·¨£¬»òµ±Ç°¶ÔÏóµÄij¸ö³ÉÔ±£¬Äã±ã¿ÉÒÔÀûÓÃthisÀ´ÊµÏÖÕâ¸öÄ¿µÄ£¬µ±È»£¬thisµÄÁíÒ»¸öÓÃ;Êǵ÷Óõ±Ç°¶ÔÏó
µÄÁíÒ»¸ö¹¹Ô캯Êý£¬ÕâЩÂíÉϾÍÒªÌÖÂÛ¡£Èç¹ûÄãÏëÒýÓø¸ÀàµÄijÖÖ¶«Î÷£¬Ôò·ÇsuperĪÊô¡£ÓÉÓÚthisÓësuperÓÐÈç´ËÏàËƵÄһЩÌØÐÔºÍÓëÉú¾ãÀ´µÄijÖÖ
¹Øϵ£¬ËùÒÔÎÒÃÇÔÚÕâÒ»¿é¶ùÀ´ÌÖÂÛ£¬Ï£ÍûÄÜ°ïÖúÄãÇø·ÖºÍÕÆÎÕËüÃÇÁ½¸ö¡£
¡¡¡¡ÔÚÒ»°ã·½·¨ÖÐ
¡¡¡¡×îÆÕ±éµÄÇé¿ö¾ÍÊÇ£¬ÔÚÄãµÄ·½·¨
ÖеÄij¸öÐβÎÃûÓ뵱ǰ¶ÔÏóµÄij¸ö³ÉÔ±ÓÐÏàͬµÄÃû×Ö£¬ÕâʱΪÁ˲»ÖÁÓÚ»ìÏý£¬Äã±ãÐèÒªÃ÷ȷʹÓÃthis¹Ø¼ü×ÖÀ´Ö¸Ã÷ÄãҪʹÓÃij¸ö³ÉÔ±£¬Ê¹Ó÷½·¨ÊÇ“this.
³ÉÔ±Ãû”£¬¶ø²»´øthisµÄÄǸö±ãÊÇÐβΡ£ÁíÍ⣬»¹¿ÉÒÔÓÓthis.·½·¨Ãû”À´ÒýÓõ± ......
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.getIns ......
¡¡
¡¡ÔÚJavaÖУ¬thisͨ³£Ö¸µ±Ç°¶ÔÏó£¬superÔòÖ¸¸¸ÀàµÄ¡£µ±ÄãÏëÒªÒýÓõ±Ç°¶ÔÏóµÄijÖÖ¶«Î÷£¬±ÈÈ統ǰ¶ÔÏóµÄij¸ö·½·¨£¬»òµ±Ç°¶ÔÏóµÄij¸ö³ÉÔ±£¬Äã±ã
¿ÉÒÔÀûÓÃthisÀ´ÊµÏÖÕâ¸öÄ¿µÄ£¬µ±È»£¬thisµÄÁíÒ»¸öÓÃ;Êǵ÷Óõ±Ç°¶ÔÏóµÄÁíÒ»¸ö¹¹Ô캯Êý£¬ÕâЩÂíÉϾÍÒªÌÖÂÛ¡£Èç¹ûÄãÏëÒýÓø¸ÀàµÄijÖÖ¶«Î÷£¬Ôò·Ç
superĪÊô¡£ÓÉÓÚthisÓësuperÓÐÈç´ËÏàËƵÄһЩÌØÐÔºÍÓëÉú¾ãÀ´µÄijÖÖ¹Øϵ£¬ËùÒÔÎÒÃÇÔÚÕâÒ»¿é¶ùÀ´ÌÖÂÛ£¬Ï£ÍûÄÜ°ïÖúÄãÇø·ÖºÍÕÆÎÕËüÃÇÁ½¸ö¡£
ÔÚÒ»°ã·½·¨ÖÐ
¡¡
¡¡×îÆÕ±éµÄÇé¿ö¾ÍÊÇ£¬ÔÚÄãµÄ·½·¨ÖеÄij¸öÐβÎÃûÓ뵱ǰ¶ÔÏóµÄij¸ö³ÉÔ±ÓÐÏàͬµÄÃû×Ö£¬ÕâʱΪÁ˲»ÖÁÓÚ»ìÏý£¬Äã±ãÐèÒªÃ÷ȷʹÓÃthis¹Ø¼ü×ÖÀ´Ö¸Ã÷ÄãҪʹÓÃij
¸ö³ÉÔ±£¬Ê¹Ó÷½·¨ÊÇ“this.³ÉÔ±Ãû”£¬¶ø²»´øthisµÄÄǸö±ãÊÇÐβΡ£ÁíÍ⣬»¹¿ÉÒÔÓÓthis.·½·¨Ãû”À´ÒýÓõ±Ç°¶ÔÏóµÄij¸ö·½·¨£¬µ«Õâʱthis
¾Í²»ÊDZØÐëµÄÁË£¬Äã¿ÉÒÔÖ±½ÓÓ÷½·¨ÃûÀ´·ÃÎÊÄǸö·½·¨£¬±àÒëÆ÷»áÖªµÀÄãÒªµ÷ÓõÄÊÇÄÇÒ»¸ö¡£ÏÂÃæµÄ´úÂëÑÝʾÁËÉÏÃæµÄÓ÷¨£º
public class DemoThis{
private String name;
private int age;
DemoThis(String name,int age){
setName(name); //Äã¿ÉÒÔ¼ÓÉ ......