Friday, June 10, 2016

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

c++ - Does curly brackets matter for empty constructor?

Those brackets declare an empty, inline constructor. In that case, with them, the constructor does exist, it merely does nothing more than t...