翻過(guò)高山走不出你
2022-09-07 17:06:04
我有這個(gè)代碼,我想知道為什么它返回正確的日期Festival f= (Festival) festival.get(0);Date d=f.getSDate();System.out.println(d.getYear());System.out.println(d.getMonth());System.out.println(d.getDate());SimpleDateFormat df = new SimpleDateFormat("dd/MM/yyyy"); // define your format.String formattedDate = df.format(d);System.out.println("New Date To Show::"+formattedDate);輸出是這個(gè)2019227New Date To Show::27/03/3919
2 回答

慕娘9325324
TA貢獻(xiàn)1783條經(jīng)驗(yàn) 獲得超4個(gè)贊
嘗試使用這個(gè):
Date date=new Date();
// you can assign your return from the function here
LocalDate localDate = date.toInstant().atZone(ZoneId.systemDefault()).toLocalDate();
System.out.println(localDate.getMonthValue());
System.out.println(localDate.getDayOfMonth());
System.out.println(localDate.getYear());
SimpleDateFormat df = new SimpleDateFormat("dd/MM/yyyy");
String formattedDate = df.format(date);
System.out.println("New Date To Show::"+formattedDate);
添加回答
舉報(bào)
0/150
提交
取消