Thursday, August 15, 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

hard drive - Leaving bad sectors in unformatted partition?

Laptop was acting really weird, and copy and seek times were really slow, so I decided to scan the hard drive surface. I have a couple hundr...