Thursday 15 August 2019

java - I have created a date using SimpleDateFormat, how do I convert into a string?

newDate =(newDaysAdded+"/"+month+"/"+year); 
SimpleDateFormat date = new SimpleDateFormat("dd/MM/yyyy");
try {
Date newDateOne = date.parse(newDate);


When I try:




view.writeToScreen(newDateOne);


I get the error:



 Incompatible types: Date cannot be converted to String.


Here is the writeToScreen method:




void writeToScreen(String s);


However from there I can't turn into a string, I have tried:
String test = Date.toString(newDateOne);



Can anyone help?

No comments:

Post a Comment

php - file_get_contents shows unexpected output while reading a file

I want to output an inline jpg image as a base64 encoded string, however when I do this : $contents = file_get_contents($filename); print &q...