static ArrayList<String> list = new ArrayList<>();
public static void main(String[] args) throws IOException, ParseException {
forDate();
String s2 = "{start-date:2022-5-1,end-date:2022-8-1\"status\":200,\"msg\":\"写入redis操作成功\",\"content\":null,\"error\":false}";
StringBuilder stringBuilder = new StringBuilder();
stringBuilder.append(s2.substring(0, s2.indexOf("2022")));
int index = 0;
//FileOutputStream fileOutputStream = new FileOutputStream(new File("D:\\1.txt"));
while (index < list.size()){
stringBuilder.append(list.get(index++));
stringBuilder.append(",end-date:");
stringBuilder.append("2022-8-1");
stringBuilder.append("\"status\":200,\"msg\":\"写入redis操作成功\",\"content\":null,\"error\":false}");
//fileOutputStream.write(stringBuilder.toString().getBytes());
System.out.println(stringBuilder.toString());
stringBuilder=new StringBuilder();
stringBuilder.append(s2.substring(0, s2.indexOf("2022")));
}
}
public static void forDate() {
int res = 0;
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
try {
Date d1 = sdf.parse("2022-7-29");
Date d2 = sdf.parse("2022-8-1");
Date tmp = d1;
Calendar dd = Calendar.getInstance();
dd.setTime(d1);
while (tmp.getTime() < d2.getTime()) {
tmp = dd.getTime();
//System.out.println(sdf.format(tmp));
list.add(sdf.format(tmp));
res++;
dd.add(Calendar.DAY_OF_MONTH, 1);
}
System.out.println(res);
} catch (ParseException e) {
e.printStackTrace();
}
}