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

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


Ïà¹ØÎĵµ£º

JavaÖÐByteÐÍת×Ö·û´®

public static String byteToString(byte src)
{
    String desc = null;
    int i = 0;    //È¡1¸ö×Ö½Ú
    i = src&0xFF;
    desc = Integer.toHexString(i);
    if (desc.length() == 1) ......

Java ¶ÔÏóÐòÁл¯

Java 1.1ÔöÌíÁËÒ»ÖÖÓÐȤµÄÌØÐÔ£¬ÃûΪ¡°¶ÔÏóÐòÁл¯¡±£¨Object Serialization£©¡£ËüÃæÏòÄÇЩʵÏÖÁËSerializable½Ó¿ÚµÄ¶ÔÏ󣬿ɽ«ËüÃÇת»»³ÉһϵÁÐ×Ö½Ú£¬²¢¿ÉÔÚÒÔºóÍêÈ«»Ö¸´»ØÔ­À´µÄÑù×Ó¡£ÕâÒ»¹ý³ÌÒà¿Éͨ¹ýÍøÂç½øÐС£ÕâÒâζ×ÅÐòÁл¯»úÖÆÄÜ×Ô¶¯²¹³¥²Ù×÷ϵͳ¼äµÄ²îÒì¡£»»¾ä»°Ëµ£¬¿ÉÒÔÏÈÔÚWindows»úÆ÷ÉÏ´´½¨Ò»¸ö¶ÔÏó£¬¶ÔÆäÐòÁл¯£ ......

Java ÈÕÆÚ¼Ó減

public static void main(String[] args) {
   String DATE_FORMAT = "yyyy-MM-dd";
   java.text.SimpleDateFormat sdf = new java.text.SimpleDateFormat(
     DATE_FORMAT);
   Calendar c1 = Calendar.getInstance();
   c1.set(1999, 0, 14);
&n ......

JAVAÏß³ÌÖ®Î壺Ï̵߳Äͬ²½

      Èç¹û³ÌÐòÊǵ¥Ị̈߳¬Ö´ÐÐÆðÀ´²»±Øµ£ÐÄ´ËÏ̻߳ᱻÆäËûÏ̴߳òÈÅ£¬¾ÍÏñÔÚÏÖʵÖУ¬Í¬Ò»Ê±¼äÖ»Íê³ÉÒ»¼þÊÂÇ飬¿ÉÒÔ²»Óõ£ÐÄÕâ¼þÊÂÇé»á±»ÆäËûÊÂÇé´òÈÅ¡£µ«ÊÇÈç¹û³ÌÐòÖÐͬʱʹÓöàỊ̈߳¬¾ÍºÃ±ÈÏÖʵÖГÁ½¸öÈËͬʱ½øÈëÒ»ÉÈÃÅ”£¬´Ëʱ¾ÍÐèÒª¿ØÖÆ£¬·ñÔòÈÝÒ××èÈû¡£ÎªÁ˱ÜÃâ¶àÏ̹߳²Ïí×ÊÔ´·¢Éú³ ......
© 2009 ej38.com All Rights Reserved. ¹ØÓÚE½¡ÍøÁªÏµÎÒÃÇ | Õ¾µãµØÍ¼ | ¸ÓICP±¸09004571ºÅ