如何从java中给定日期获取最近30/60/90天的记录?
我有一些与receiveDate有关的记录。我想从收到的日期获取过去30或60或90天的记录。怎么解决呢?
最佳答案
Date today = new Date();
Calendar cal = new GregorianCalendar();
cal.setTime(today);
cal.add(Calendar.DAY_OF_MONTH, -30);
Date today30 = cal.getTime();
cal.add(Calendar.DAY_OF_MONTH, -60);
Date today60 = cal.getTime();
cal.add(Calendar.DAY_OF_MONTH, -90);
Date today90 = cal.getTime();
关于java - 在Java中找出最近30天,60天和90天,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/979469/