Java calculates the intermediate days based on the start time and end time, and prints
import java.text.simpledateformat;import java.util.date;public class calcdate { static simpledateformat sdf = new simpledateformat ("Yyyy-MM-dd hh:mm:ss "); static simpledateformat ymd = new SimpleDateFormat ("Yyyy-mm-dd"); public static void main (String[] args) throws exception{ date begintime = Sdf.parse ("2015-04-23 12:32:44");// date endtime = sdf.parse ("2015-04-23 14:56:44"); date Endtime = sdf.parse ("2015-04-29 14:56:44"); long diff = (Endtime.gettime () - begintime.gettime ()) / (86400 * 1000 ); &nbsP; system.out.println ("diff = " + diff); date sb = null; date se = null; if (diff == 0) { sb = beginTime; se = endTime; string ss = string.format ("%d> sb=%s, se=%s", 1, coder.datetimetostr (SB), coder.datetimetostr (SE)); &NBSP;&NBSP;&NBSP;&NBSP;SYSTEM.OUT.PRINTLN (ss); }else { int i = 0; while (I <= diff) { if (i == 0) { sb = beginTime; se = sdf.parse (Ymd.format (SB) + " 23:59:59"); } else if (I == diff) { sb = sdf.parse (Ymd.format (endTime) + " 00:00:00"); se = endtime; } else { se = new date (Begintime.gettime () + i * 24 * 60 * 60 * 1000); sb = sdf.parse (Ymd.format (SE ) + " 00:00:00"); se = sdf.parse (Ymd.format (SE) + " 23:59:59" ); } String ss = string.format ("%d> sb=%s, se=%s ", i, coder.datetimetostr (Sb), coder.datetimetostr (Se)); &NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;SYSTEM.OUT.PRINTLN (ss); i++; } } }}
diff = 60> sb=2015-04-23 12:32:44, se=2015-04-23 23:59:591> sb=2015-04-24 00:00:00, se=2015-04-24 23:59:592> Sb= 2015-04-25 00:00:00, se=2015-04-25 23:59:593> sb=2015-04-26 00:00:00, se=2015-04-26 23:59:594> Sb=2015-04-27 00:00:00, se=2015-04-27 23:59:595> sb=2015-04-28 00:00:00, se=2015-04-28 23:59:596> Sb=2015-04-29 00:00:00, Se= 2015-04-29 14:56:44
Java calculates the intermediate days based on the start time and end time, and prints