A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://www.w3resource.com/java-tutorial/util/date/java_date_tostring.php below:

Website Navigation


Java Date toString() Method - w3resource

Java Date.toString()MethodLast update on August 19 2022 21:51:24 (UTC/GMT +8 hours) public String toString()

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