目录

static ZonedDateTime parse(CharSequence text)

描述 (Description)

java.time.ZonedDateTime.parse(CharSequence text)方法从文本字符串中获取ZonedDateTime的实例,例如2007-12-03T10:15:30 + 01:00 [Europe/Paris]。

声明 (Declaration)

以下是java.time.ZonedDateTime.parse(CharSequence text)方法的声明。

public static ZonedDateTime parse(CharSequence text)

参数 (Parameters)

text - 要解析的文本,例如“2007-12-03T10:15:30 + 01:00 [Europe/Paris]”,不为空。

返回值 (Return Value)

本地日期,不为空。

异常 (Exceptions)

DateTimeParseException - 如果无法解析文本。

例子 (Example)

以下示例显示了java.time.ZonedDateTime.parse(CharSequence text)方法的用法。

package com.iowiki;
import java.time.ZonedDateTime;
public class ZonedDateTimeDemo {
   public static void main(String[] args) {
      ZonedDateTime date = ZonedDateTime.parse("2017-03-28T12:25:38.492+05:30[Asia/Calcutta]");
      System.out.println(date);  
   }
}

让我们编译并运行上面的程序,这将产生以下结果 -

2017-03-28T12:25:38.492+05:30[Asia/Calcutta]
↑回到顶部↑
WIKI教程 @2018