Dieser Artikel hat den Java -Schnittdatum und den Zeitraum für Ihre Referenz geteilt. Der spezifische Inhalt ist wie folgt
/** * @Author Dy * @Since 2016-09-18 & JDK 1.8.0_91 */public class datEcalculate {static logger logger = loggerfactory.getLogger (datEcalculate.class); /** * Schnittzeitraum * * @param datetype Transaktionstyp m/d/h/n-> monatlich/tag/stündlich/min * @param start yyyy-mm-dd hh: mm: ss * @param end yyyyyyyyyyyyyyyyyyyyyyy-mm-hh: mm: ss * @return */public static liste < = new SimpledateFormat ("yyyy-mm-dd hh: mm: ss"); Datum dBegin = sdf.parse (start); Datum Dend = SDF.Parse (Ende); return finddates (datetyp, dbegin, dend); } catch (Ausnahme e) {logger.Error (e.getMessage (), e); } return null; } public static list <string> findDates (String DateType, Datum Debin, Datum Dend) löst Ausnahme aus {list <string> listDate = new ArrayList <> (); Kalender CalBegin = Calendar.getInstance (); CalBegin.Settime (dBegin); Kalender calend = Calendar.getInstance (); kalend.settime (dend); while (calend.after (calBegin)) {switch (datetyp) {case "m": calBegin.add (Calendar.monate, 1); brechen; Fall "D": CalBegin.Add (Calendar.day_of_year, 1); Break; Fall "H": CalBegin.Add (Kalender.Hour, 1); Break; Fall "n": CalBegin.add (Calendar.second, 1); Break; } if (calend.after (calBegin)) listDate.add (new SimpledateFormat ("yyyy-mm-dd hh: mm: ss"). Format (CalBin.getTime ())); sonst listDate.add (new SimpledateFormat ("yyyy-mm-dd hh: mm: ss"). Format (calend.getTime ()); } return listDate; } public static void main (String [] args) {String start = "2016-02-01 00:00:00"; String end = "2016-03-02 00:00:00"; List <String> list = CutDate ("D", Start, Ende); für (string str: list) {system.out.println (str); }}}Das obige ist der gesamte Inhalt dieses Artikels. Ich hoffe, es wird für das Lernen aller hilfreich sein und ich hoffe, jeder wird Wulin.com mehr unterstützen.