java¼ÆËãʱ¼ä²î
java¼ÆËãʱ¼ä²î
ÎÄÕ·ÖÀà:Java±à³Ì
±ÈÈ磺ÏÖÔÚÊÇ2004-03-26 13£º31£º40
¹ýÈ¥ÊÇ£º2004-01-02 11£º30£º24
ÎÒÏÖÔÚÒª»ñµÃÁ½¸öÈÕÆÚ²î£¬²îµÄÐÎʽΪ£ºXXÌìXXСʱXX·ÖXXÃë
·½·¨Ò»£º
DateFormat df = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
try
{
Date d1 = df.parse("2004-03-26 13:31:40");
Date d2 = df.parse("2004-01-02 11:30:24");
long diff = d1.getTime() - d2.getTime();
long days = diff / (1000 * 60 * 60 * 24);
}
catch (Exception e)
{
}
·½·¨¶þ£º
SimpleDateFormat df = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
java.util.Date now = df.parse("2004-03-26 13:31:40");
java.util.Date date=df.parse("2004-01-02 11:30:24");
long l=now.getTime()-date.getTime();
long day=l/(24*60*60*1000);
long hour=(l/(60*60*1000)-day*24);
long min=((l/(60*1000))-day*24*60-hour*60);
long s=(l/1000-day*24*60*60-hour*60*60-min*60);
System.out.println(""+day+"Ìì"+hour+"Сʱ"+min+"·Ö"+s+"Ãë");
·½·¨Èý£º
SimpleDateFormat dfs = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
java.util.Date begin=dfs.parse("2004-01-02 11:30:24");
java.util.Date end = dfs.parse("2004-03-26 13:31:40");
long between=(end.getTime()-begin.getTime())/1000;//³ýÒÔ1000ÊÇΪÁËת»»³ÉÃë
long day1=between/(24*3600);
long hour1=between%(24*3600)/3600;
long minute1=between%3600/60;
long second1=between%60/60;
System.out.println(""+day1+"Ìì"+hour1+"Сʱ"+minute1+"·Ö"+second1+"Ãë");
====================================================
java ±È½Ïʱ¼ä´óС
String s1="2008-01-25 09:12:09";
String s2="2008-01-29 09:12:11";
java.text.DateFormat df=new java.text.SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
java.util.Calendar c1=java.util.Calendar.getInstance();
java.util.Calendar c2=java.util.Calendar.getInstance();
try
{
c1.setTime(df.parse(s1));
c2.setTime(df.parse(s2));
}catch(java.text.ParseException e){
System.err.println("¸ñʽ²»ÕýÈ·");
}
int result=c1.compareTo(c2);
if(result==0)
S
Ïà¹ØÎĵµ£º
ÏÈÀ´Á˽âÒ»ÏÂÁ´±íģʽµÄÔÀí£º
Ê×ÏÈдһ¸öJavaBean£¬ÄÚÈÝÊÇÒªÌí¼ÓµÄÔªËØºÍ¸ÃÔªËØµÄ½Úµã¡£
public class NodeBean implements Serializable
{
private Object data; //ÔªËØ±¾Éí
private NodeBean next; //ÏÂÒ»¸ö½Úµã
&n ......
JavaÉè¼ÆÄ£Ê½Ö®Facadeģʽ GOF¡¶Éè¼ÆÄ£Ê½¡·Ò»Êé¶ÔFacadeģʽÊÇÕâÑùÃèÊöµÄ:
¡¡¡¡Îª×ÓϵͳÖеÄÒ»×é½Ó¿ÚÌṩһ¸öͳһ½Ó¿Ú¡£Facadeģʽ¶¨ÒåÁËÒ»¸ö¸ü¸ß²ãµÄ½Ó¿Ú£¬Ê¹×Óϵͳ¸ü¼ÓÈÝÒ×ʹÓá£
¡¡¡¡´óÖÂÒâ˼ÊÇ˵£ºÊ¹ÓÃÒ»ÖÖ±ÈÔÓз½Ê½¸ü¼òµ¥µÄ°ì·¨Óëϵͳ½»»¥¡£ÀýÈ磬ÎÒÃǰÑÒ»¸öºÜÖØÒªµÄÎļþ£¬·ÅÔÚÁ˵ڶþ³éÌëÀ¶øµÚ¶þ¸ö³éÌëµÄÔ ......
¡¾51CTO¾«Ñ¡ÒëÎÄ¡¿ÔÚ±¾ÆªÎÄÕÂÖУ¬ÖøÃû³ÌÐòÔ±Justin JamesÌÖÂÛÁËJavaµÄδÀ´£¬ÒÔ¼°JavaÓë.NETµÄ¿ª·¢³É±¾¶Ô±È£¬ºÍJavaÊÇ·ñÄܹ»È¡´ú.NET¡£JustinÔÚÎÄÖÐ×ܽáÁËËÄ´óÒªµã£¬ÖØµã¹Ø×¢ÁËÁ½¸öÔËÐÐʱÔÚÐÔÄܺͳɱ¾ÉϵÄÒì֮ͬ´¦¡£
1¡¢Java SE 7ÔâÓö.NET CLR»á·¢Éúʲô£¿
´ÓJava SE 7µÄ¹¦ÄÜÁбíÖпÉÒÔ¿´³ö£¬ËüÏà±ÈÒÔǰ°æ±¾ÓÐÁ˳¤×ãÌá¸ß¡£ ......
½ñÌì·Å¼ÙÒ»Ì죬֮ǰµÄѧϰÈÃÎҸоõÂäÏÂÐí¶à£¬ËùÒÔÔçÉÏÔçÔçµÄÆðÀ´ÔÚÕâÀïд´úÂë ²¹¹¦¿ÎÀ²¡£ForÑ»·´ó¼ÒÓ¦¸Ã²»»áİÉú°É£¬½ñÌì°ÑforÔÙ´ÎÊìϤÏ£¬¹®¹Ì֪ʶÂï¡£
µÚÒ»£¬ÔöÇ¿forµÄʹÓÃÌõ¼þ£º
1.Êý×é 2.Iterator µü´úÆ÷
µÚ¶þ£¬´«Í³FORÓëÔöÇ¿FORµÄ¾ÙÀý±È½Ï:
& ......