1Calendar cal = Calendar.getInstance();
2cal.set(year,month-1,day);
3int nd = cal.get(Calendar.DAY_OF_WEEK);
1LocalDateTime now = LocalDateTime.now();
2int year = now.getYear();
3int month = now.getMonthValue();
4int day = now.getDayOfMonth();
5int hour = now.getHour();
6int minute = now.getMinute();
7int second = now.getSecond();
8int millis = now.get(ChronoField.MILLI_OF_SECOND); // Note: no direct getter available.
9
10System.out.printf("%d-%02d-%02d %02d:%02d:%02d.%03d", year, month, day, hour, minute, second, millis);
11