public static void main(String[] args) { LocalDateTime time = LocalDateTime.of(2022,11,30,6,6,6); DateTimeFormatter of = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss"); String dateTime = time.format(of); System.out.println(dateTime); // Date date = new Date(2022,10,30,6,6,6); SimpleDateFormat sdf4 = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); System.out.println(sdf4.format(date)); Calendar calendar = Calendar.getInstance(); calendar.set(2022,10,30,6,6,6); System.out.println(sdf4.format(calendar.getTime())); /**LocalDateTime now =LocalDateTime.now(); DateTimeFormatter of = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss"); String dateTime = now.format(of); System.out.println(dateTime); // Calendar calendar = Calendar.getInstance(); Date d = calendar.getTime(); //calendar.set(2022,10,30,6,6,6); SimpleDateFormat sdf4 = new SimpleDateFormat("yyyy年MM月dd日 HH时mm分ss秒"); System.out.println(sdf4.format(d)); Date date = new Date(); System.out.println(sdf4.format(date));**/ }
标签:sdf4,java,format,System,时间,println,操作,calendar,out From: https://www.cnblogs.com/leiqun123/p/18065443