Ò׽ؽØͼÈí¼þ¡¢µ¥Îļþ¡¢Ãâ°²×°¡¢´¿ÂÌÉ«¡¢½ö160KB

JAVA´¦ÀíÈÕÆÚʱ¼ä³£Ó÷½·¨


Calendar ÀàÊÇÒ»¸ö³éÏóÀ࣬ËüΪÌض¨Ë²¼äÓëÒ»×éÖîÈç YEAR¡¢MONTH¡¢DAY_OF_MONTH¡¢HOUR µÈ ÈÕÀú×Ö¶ÎÖ®¼äµÄת»»ÌṩÁËһЩ·½·¨£¬²¢Îª²Ù×÷ÈÕÀú×ֶΣ¨ÀýÈç»ñµÃÏÂÐÇÆÚµÄÈÕÆÚ£©ÌṩÁËһЩ·½·¨¡£Ë²¼ä¿ÉÓúÁÃëÖµÀ´±íʾ£¬ËüÊǾàÀúÔª£¨¼´¸ñÁÖÍþÖαê׼ʱ¼ä 1970 Äê 1 Ô 1 ÈÕµÄ 00:00:00.000£¬¸ñÀï¸ßÀûÀú£©µÄÆ«ÒÆÁ¿¡£
Àý:
Calendar cal = Calendar.getInstance();//ʹÓÃĬÈÏʱÇøºÍÓïÑÔ»·¾³»ñµÃÒ»¸öÈÕÀú¡£
cal.add(Calendar.DAY_OF_MONTH, -1);//È¡µ±Ç°ÈÕÆÚµÄÇ°Ò»Ìì.
cal.add(Calendar.DAY_OF_MONTH, +1);//È¡µ±Ç°ÈÕÆڵĺóÒ»Ìì.
//ͨ¹ý¸ñʽ»¯Êä³öÈÕÆÚ
java.text.SimpleDateFormat format = new java.text.SimpleDateFormat("yyyy-MM-dd");
System.out.println("Today is:"+format.format(Calendar.getInstance().getTime()));
System.out.println("yesterday is:"+format.format(cal.getTime()));
µÃµ½2007-12-25ÈÕÆÚ:
Calendar calendar = new GregorianCalendar(2007, 11, 25,0,0,0);
Date date = calendar.getTime();
System.out.println("2007 Christmas is:"+format.format(date));
//javaÔ·ÝÊÇ´Ó0-11,Ô·ÝÉèÖÃʱҪ¼õ1.
//GregorianCalendar¹¹Ôì·½·¨²ÎÊýÒÀ´ÎΪ£ºÄ꣬ÔÂ-1£¬ÈÕ£¬Ê±£¬·Ö£¬Ãë.
È¡ÈÕÆڵIJ¿·Ö:
int year =calendar.get(Calendar.YEAR);
int month=calendar.get(Calendar.MONTH)+1;
int day =calendar.get(Calendar.DAY_OF_MONTH);
int hour =calendar.get(Calendar.HOUR_OF_DAY);
int minute =calendar.get(Calendar.MINUTE);
int seconds =calendar.get(Calendar.SECOND);
È¡Ô·ÝÒª¼Ó1.
Åжϵ±Ç°Ô·ݵÄ×î´óÌìÊý:
Calendar cal = Calendar.getInstance();
int day=cal.getActualMaximum(Calendar.DAY_OF_MONTH);
System.out.println(day);
<!--[if !supportLineBreakNewLine]-->
<!--[endif]-->
<!--[if !supportLists]-->2.    <!--[endif]-->java.util.Date
Àà Date±íʾÌض¨µÄ˲¼ä£¬¾«È·µ½ºÁÃë¡£´Ó JDK 1.1 ¿ªÊ¼£¬Ó¦¸ÃʹÓà Calendar ÀàʵÏÖÈÕÆÚºÍʱ¼ä×Ö¶ÎÖ®¼äת»»£¬Ê¹Óà DateFormat ÀàÀ´¸ñʽ»¯ºÍ·ÖÎöÈÕÆÚ×Ö·û´®¡£Date ÖеÄÏàÓ¦·½·¨ÒÑ·ÏÆú¡£
¾¡¹Ü Date Àà´òË㷴ӳЭµ÷ÊÀ½çʱ (UTC)£¬µ«ÎÞ·¨×öµ½Èç´Ë׼ȷ£¬ÕâÈ¡¾öÓÚ Java ÐéÄâ»úµÄÖ÷»ú»·¾³¡£µ±Ç°¼¸ºõËùÓвÙ×÷ϵͳ¶¼¼Ù¶¨ 1 Ìì = 24 × 60 × 60 = 86400 Ãë¡£µ«¶ÔÓÚ UTC£¬´óԼÿһÁ½Ä


Ïà¹ØÎĵµ£º

Java¶àÏß³Ì Éú²úÕßÏû·ÑÕßÎÊÌâ (2)

Ò»¸öʹÓÃÁ˶ÓÁеÄͨÓÃʵÏÖ£º
http://blog.csdn.net/chaosllgao/archive/2009/05/23/4211183.aspx
 ´ËÎÄÃèÊöÁËÒ»ÖÖ¸ü¼òµ¥µÄÄ£ÐÍ
 1. ͬʱֻÓÐ1¸öÉú²úÕߺÍ1¸öÏû·ÑÕß
 2. ²»ÓöÓÁУ¬Í¬Ê±Ö»ÓÐÒ»¸ö²úÆ·
 3. Éú²úÕßÿ´ÎÉú²ú1¸ö0µ½100Ö®¼äµÄËæ»úÊý£¬Ïû·ÑÕßÔò°Ñ¸ÃËæ»úÊý´òÓ¡³öÀ´¡£Èç¹û²úÉúµÄËæ»úÊýΪ0£¬Ôò ......

javaµãµÎ1

String Óë StringBufferÇø±ð:
String×Ö·û´®¶ÔÏóÊDz»¿É±äµÄ£»StringBufferÊDZ䳤ºÍ¿ÉдµÄ¶¯Ì¬×Ö·ûÐòÁУ¬¿ÉÒÔ×Ô¶¯µØÔö¼Ó¿Õ¼ä¡£
Integer var = new Integer();//ÓÐÓï·¨´íÎó
Integer var = new Integer(2);//悦﵀
javaµÄVector³ÉÔ±ÊÇÒªÓÃelementAt(i)³ÉÔ±º¯ÊýÀ´»ñµÃµÄ£¬²»ÄÜÓÃve[i]µÃµ½¡£
Vector::public Enumeration< ......

java×ÔѧµãµÎ


String Óë StringBufferÇø±ð:
String×Ö·û´®¶ÔÏóÊDz»¿É±äµÄ£»StringBufferÊDZ䳤ºÍ¿ÉдµÄ¶¯Ì¬×Ö·ûÐòÁУ¬¿ÉÒÔ×Ô¶¯µØÔö¼Ó¿Õ¼ä¡£
Integer var = new Integer();//ÓÐÓï·¨´íÎó
Integer var = new Integer(2);//悦﵀
javaµÄVector³ÉÔ±ÊÇÒªÓÃelementAt(i)³ÉÔ±º¯ÊýÀ´»ñµÃµÄ£¬²»ÄÜÓÃve[i]µÃµ½¡£
Vector::public Enumeration& ......

Java±à³Ì¹æ·¶

 packageµÄÃüÃû package µÄÃû×ÖÓÉÈ«²¿Ð¡Ð´µÄ×Öĸ×é³É£¬ÀýÈ磺cn.mybole¡£
classºÍinterfaceµÄÃüÃû classºÍinterfaceµÄÃû×ÖÓÉ´óд×Öĸ¿ªÍ·¶øÆäËû×Öĸ¶¼Ð¡Ð´µÄµ¥´Ê×é³É£¬ÀýÈ磺Person£¬RuntimeException¡£
class±äÁ¿µÄÃüÃû ±äÁ¿µÄÃû×ÖÓÃÒ»¸öСд×Öĸ¿ªÍ·£¬ºóÃæµÄµ¥´ÊÓôóд×Öĸ¿ªÍ·,ÀýÈ磺index£¬currentImage¡£
clas ......

Java¶àÏ̱߳à³ÌÏê½â

Ò»£ºÀí½â¶àÏß³Ì
¶àÏß³ÌÊÇÕâÑùÒ»ÖÖ»úÖÆ£¬ËüÔÊÐíÔÚ³ÌÐòÖв¢·¢Ö´Ðжà¸öÖ¸ÁîÁ÷£¬Ã¿¸öÖ¸ÁîÁ÷¶¼³ÆΪһ¸öỊ̈߳¬±Ë´Ë¼ä»¥Ïà¶ÀÁ¢¡£
Ïß³ÌÓÖ³ÆΪÇáÁ¿¼¶½ø³Ì£¬ËüºÍ½ø³ÌÒ»ÑùÓµÓжÀÁ¢µÄÖ´ÐпØÖÆ£¬ÓɲÙ×÷ϵͳ¸ºÔðµ÷¶È£¬Çø±ðÔÚÓÚÏß³ÌûÓжÀÁ¢µÄ´æ´¢¿Õ¼ä£¬¶øÊǺÍËùÊô½ø³ÌÖеÄÆäËüÏ̹߳²ÏíÒ»¸ö´æ´¢¿Õ¼ä£¬ÕâʹµÃÏ̼߳äµÄͨÐÅÔ¶½Ï½ø³Ì¼òµ¥¡£ ......
© 2009 ej38.com All Rights Reserved. ¹ØÓÚE½¡ÍøÁªÏµÎÒÃÇ | Õ¾µãµØͼ | ¸ÓICP±¸09004571ºÅ