The toString() method is used to convert an Date object to a string of the form: dow mon dd hh:mm:ss zzz yyyy
Where:
Package: java.util
Java Platform: Java SE 8
Syntax:
toString()
Return Value:
a string representation of this date.
Return Value Type: string
Example: Java Date.toString() Method
import java.util.Date;
public class Main {
public static void main(String[] args) {
// create a date
Date date = new Date(2012, 2, 2);
// Converts the said Date object to String
String str_date = date.toString();
System.out.println(str_date);
}
}
Output:
Sat Mar 02 00:00:00 UTC 3912
Java Code Editor:
Previous:toInstant Method
Next:Arraydeque Class Methods Home
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4