privatestatic SimpleDateFormat SDFT = new SimpleDateFormat("yyyy-MM-dd");
publicstaticvoidmain(String[] args){ for (int i = 1; i < 31; i++) { int ii = i; new Thread(() -> { Date date = null; try { String s = "2019-05-" + ii; date = SDFT.parse(s); System.out.println("" + ii + ":" + date.getDate()); } catch (ParseException e) { e.printStackTrace(); } }).start(); } }
publicstaticvoidmain(String[] args){ for (int i = 1; i < 31; i++) { int ii = i; new Thread(() -> { Date date = null; try { String s = "2019-05-" + ii; date = new SimpleDateFormat("yyyy-MM-dd").parse(s); System.out.println("" + ii + ":" + date.getDate()); } catch (ParseException e) { e.printStackTrace(); } }).start(); } }
publicstaticvoidmain(String[] args){ for (int i = 1; i < 31; i++) { int ii = i; new Thread(() -> { Date date = null; try { String s = "2019-05-" + ii; date = threadLocal.get().parse(s); System.out.println("" + ii + ":" + date.getDate()); } catch (ParseException e) { e.printStackTrace(); } }).start(); } }