java 时间比较
程序员文章站
2022-04-04 21:23:19
...
public class test { public static void main(String[] args) { // System.out.println( (0 << 3) | 7); long epoch = System.currentTimeMillis() / 1000; System.out.println(epoch); DateFormat df = new SimpleDateFormat("HH:mm:ss"); String dateString = df.format(new Date(epoch * 1000)); System.out.println(dateString); try { Date dt1 = df.parse(dateString); System.out.println(dt1); Date dt2 = df.parse("07:00:00"); System.out.println(dt2); if (dt1.getTime() > dt2.getTime()) { System.out.println(dt1.getTime() + "------" + dt2.getTime()); System.out.println("yyyyy"); } else { System.out.println("nnnnnnn"); } } catch (ParseException e) { // TODO Auto-generated catch block e.printStackTrace(); } } }