3
我想將日曆輸出轉換爲字符串。以下是我的代碼將日曆轉換爲字符串
Calendar cal=Calendar.getInstance();
System.out.println("Time is "+cal.getTime());
String str=cal.getTime(); //This is how I want to store the output, but this is wrong.
這裏getTime()方法的輸出是'Date'類型,所以出現錯誤。 是否有任何方式來強調類型或任何解決方案?
'字符串str = cal.getTime()的toString()' – Prashant