ee.Date.parse
根据描述其格式的字符串解析日期字符串。
用法 | 返回 |
---|
ee.Date.parse(format, date, timeZone) | 日期 |
参数 | 类型 | 详细信息 |
---|
format | 字符串 | 模式,如 http://joda-time.sourceforge.net/apidocs/org/joda/time/format/DateTimeFormat.html 中所述。 |
date | 字符串 | 与给定模式匹配的字符串。 |
timeZone | 字符串,默认值:null | 时区(例如,'America/Los_Angeles');默认为世界协调时间 (UTC)。 |
示例
print(ee.Date.parse('yyyy MM dd', '2021 4 30'));
print(ee.Date.parse('yyyy-MM-dd', '2021-4-30'));
print(ee.Date.parse('yyyy/MM/dd', '2021/4/30'));
print(ee.Date.parse('MM/dd/yy', '4/30/21'));
print(ee.Date.parse('MMM. dd, yyyy', 'Apr. 30, 2021'));
print(ee.Date.parse('yyyy-MM-dd HH:mm:ss', '2021-4-30 00:00:00'));
Python 设置
如需了解 Python API 以及如何使用 geemap
进行交互式开发,请参阅
Python 环境页面。
import ee
import geemap.core as geemap
display(ee.Date.parse('YYYY MM dd', '2021 4 30'))
display(ee.Date.parse('YYYY-MM-dd', '2021-4-30'))
display(ee.Date.parse('YYYY/MM/dd', '2021/4/30'))
display(ee.Date.parse('MM/dd/YY', '4/30/21'))
display(ee.Date.parse('MMM. dd, YYYY', 'Apr. 30, 2021'))
display(ee.Date.parse('YYYY-MM-dd HH:mm:ss', '2021-4-30 00:00:00'))
如未另行说明,那么本页面中的内容已根据知识共享署名 4.0 许可获得了许可,并且代码示例已根据 Apache 2.0 许可获得了许可。有关详情,请参阅 Google 开发者网站政策。Java 是 Oracle 和/或其关联公司的注册商标。
最后更新时间 (UTC):2025-02-22。
[null,null,["最后更新时间 (UTC):2025-02-22。"],[[["`ee.Date.parse()` allows you to convert a date string into a Date object by specifying the string's format."],["It accepts a format pattern based on Joda-Time's DateTimeFormat, the date string itself, and an optional time zone (defaulting to UTC)."],["Various format patterns can be used, such as 'YYYY MM dd', 'YYYY-MM-dd', 'YYYY/MM/dd', 'MM/dd/YY', 'MMM.dd, YYYY', and 'YYYY-MM-dd HH:mm:ss'."]]],["The `ee.Date.parse` function converts a date string into a Date object. It requires a `format` string, following Joda-Time patterns, to define the structure of the input `date` string. An optional `timeZone` can be specified, defaulting to UTC. Valid examples are provided and demostrated for various formats like 'yyyy MM dd', 'yyyy-MM-dd' or 'MM/dd/yy'. The function will return a new date based on the parsing of the date string.\n"]]