- package home.userinfo;
- import java.text.ParsePosition;
- import java.text.SimpleDateFormat;
- import java.util.Date;
- public class GetDate {
- public long getdate(String d1, String d2) {
- long i = -1;
- try {
- SimpleDateFormat formatter = new SimpleDateFormat(
- "yyyy-MM-dd HH:mm:ss");
- ParsePosition pos = new ParsePosition(0);
- ParsePosition pos1 = new ParsePosition(0);
- Date dt1 = formatter.parse(d1, pos);
- Date dt2 = formatter.parse(d2, pos1);
- long l = dt1.getTime() - dt2.getTime();
- i = l / (1000 * 60 * 60 * 24);
- // 这是他们相差的天数。
- System.out.println("Hello World!=" + i);
- } catch (Exception
复制代码 |