Friday, 22 September 2017

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

casting - Why wasn't Tobey Maguire in The Amazing Spider-Man? - Movies & TV

In the Spider-Man franchise, Tobey Maguire is an outstanding performer as a Spider-Man and also reprised his role in the sequels Spider-Man...