我希望将日历输出转换成字符串。以下是我的代码。
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()方法的输出是“日期”类型,所以会出现错误。 有办法进行类型转换或有其他解决方案吗?
String str = cal.getTime().toString()
- Prashant