字符串的操作:
...
String str1 = "1234";
String str2 = "123";
String str3 = str1.replaceAll(str2, "");
...

解决方案 »

  1.   

    不知道楼主想得到什么?假如是两个时间的差值的话,需要将字符串,转为时间的类型,Java没有时间类型,假如楼主是用的数据库的话,不如直接在数据库中操作!
      

  2.   

    我想最终比较两个时间相差多少!但两个参数都是String型的   StrToDate是哪里的函数?
      

  3.   

    SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
    String a = "2002-01-01 12:12:12"; 
    String b = "2002-01-01 10:10:10";  
    Date myDateA = sdf.parse(a, new ParsePosition(0));
    Date myDateB = sdf.parse(b, new ParsePosition(0));long interval = myDateB.getTime() - myDataA.getTime();if (interval < 0) {
    //b 早于 a  interval 毫秒
    } else if ( interval = 0 ) {
    //b a 同一时刻
    }else if ( interval = 0 ) {
    //a 早于 b  interval 毫秒
    }Calendar timeInterval = Calendar.getInstance();
    timeInterval.setTimeInMillis(interval);
    int year = timeInterval.get(Calendar.YEAR);
    ....