java.time.ZonedDateTime.toString() 方法示例



說明

java.time.ZonedDateTime.toString() 方法將此日期輸出為字串,例如 2017-03-28T12:25:38.492+05:30[亞洲/加爾各答]。

宣告

以下是 java.time.ZonedDateTime.toString() 方法的宣告。

public String toString()

返回值

此日期的字串表示形式,非空。

示例

以下示例演示瞭如何使用 java.time.ZonedDateTime.toString() 方法。

package com.tutorialspoint;

import java.time.ZonedDateTime;

public class ZonedDateTimeDemo {
   public static void main(String[] args) {
 
      ZonedDateTime date = ZonedDateTime.now();
      System.out.println(date.toString());  
   }
}

讓我們編譯並執行以上程式,結果如下 -

2017-03-28T15:46:31.324+05:30[Asia/Calcutta]
廣告
© . All rights reserved.