Sunday, May 12, 2019

java - Convert Calendar to String

I want to convert Calendar output to String. The following is my code



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.


Here the output of the getTime() method is of 'Date' type, so getting error.

Is there any way to typecast or any solution?

No comments:

Post a Comment

plot explanation - Why did Peaches' mom hang on the tree? - Movies & TV

In the middle of the movie Ice Age: Continental Drift Peaches' mom asked Peaches to go to sleep. Then, she hung on the tree. This parti...