0
回答
Timestamp 和 SimpleDateFormat 的不同
滴滴云服务器,限时包月0.9元,为开发者而生>>>   
import java.sql.Timestamp;
import java.text.SimpleDateFormat;

SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");

  try {
   long a = 1L;

   long sdf1 = sdf.parse("2011-10-17 00:00:00").getTime();
   long sdf2 = sdf.parse("2011-10-18 00:00:00").getTime();

   long t1 = Timestamp.valueOf("2011-10-17 00:00:00.000").getTime();
   long t2 = Timestamp.valueOf("2011-10-17 23:59:59.999").getTime();

   if (a >= sdf1 && a < sdf2) {

    //范围1
  }
   
   if (a >= t1 && a <= t2) {

    //范围2
  }

}

范围1与范围2在何种情况下不相同呢?

举报
顶部