DateTime
コレクションでコンテンツを整理
必要に応じて、コンテンツの保存と分類を行います。
常用時(または時刻)を表します。
このタイプは、次のいずれかの方法で民間時間を表すことができます。
- utcOffset が設定され、timeZone が設定されていない場合: UTC からの特定のオフセットがある暦日の常用時。
- timeZone が設定され、utcOffset が設定されていない場合: 特定のタイムゾーンの暦日における常用時。
- timeZone と utcOffset のどちらも設定されていない場合: カレンダーの日付の常用時刻(現地時間)。
日付は先発グレゴリオ暦に基づき、
year、month、day が 0 の場合、DateTime には特定の年、月、日が設定されていないと見なされます。
この型は、すべての日時フィールドが設定され、time_offset
oneof のいずれかのケースが設定されている場合に、物理的な時刻を表すために使用することもできます。代わりに、物理的な時間には Timestamp
メッセージを使用することを検討してください。ユースケースでユーザーのタイムゾーンも保存する場合は、別のフィールドで保存できます。
このタイプは、一部のアプリケーションで必要とされるよりも柔軟性があります。アプリケーションの制限事項を必ず記録し、検証してください。
JSON 表現 |
{
"year": integer,
"month": integer,
"day": integer,
"hours": integer,
"minutes": integer,
"seconds": integer,
"nanos": integer,
// Union field time_offset can be only one of the following:
"utcOffset": string,
"timeZone": {
object (TimeZone )
}
// End of list of possible types for union field time_offset .
} |
フィールド |
year |
integer
省略可。日付の年。1 ~ 9999 の範囲で指定するか、年のない日時を指定する場合は 0 にする必要があります。
|
month |
integer
省略可。月。1 ~ 12 の範囲で指定するか、月のない日時を指定する場合は 0 にする必要があります。
|
day |
integer
省略可。日。1 ~ 31 で、その年と月に対して有効である必要があります。日を指定しない日時を指定する場合は 0 にする必要があります。
|
hours |
integer
省略可。時間(24 時間形式)。0 ~ 23 の範囲で指定します。デフォルトは 0(午前 0 時)です。API ではビジネスの終了時間などのシナリオにおいて、値 "24:00:00" を許可することもできます。
|
minutes |
integer
省略可。分。0 ~ 59 の範囲で指定します。デフォルトは 0 です。
|
seconds |
integer
省略可。秒。通常は 0 ~ 59 の範囲で指定します。デフォルトは 0 です。API がうるう秒を許可する場合、値 60 が許可されます。
|
nanos |
integer
省略可。秒の小数部分(ナノ秒単位)。0 ~ 999,999,999 の範囲で指定します。デフォルトは 0 です。
|
共用体フィールド time_offset 。省略可。UTC オフセットまたは DateTime のタイムゾーンを指定します。タイムゾーン データが将来変更される可能性があることを考慮して、慎重に選択してください(たとえば、ある国が夏時間の開始日または終了日を変更し、影響を受ける期間の将来の DateTime がすでに保存されている場合など)。省略した場合、DateTime はローカル時間と見なされます。time_offset は次のいずれかになります。 |
utcOffset |
string (Duration format)
UTC オフセット。-18 時間~+18 時間の整数秒を指定してください。たとえば、UTC オフセットが -4:00 の場合は、{ seconds: -14400 } と表されます。 s で終わる小数 9 桁までの秒単位の期間。例: "3.5s" 。
|
timeZone |
object (TimeZone )
タイムゾーン。
|
特に記載のない限り、このページのコンテンツはクリエイティブ・コモンズの表示 4.0 ライセンスにより使用許諾されます。コードサンプルは Apache 2.0 ライセンスにより使用許諾されます。詳しくは、Google Developers サイトのポリシーをご覧ください。Java は Oracle および関連会社の登録商標です。
最終更新日 2025-08-29 UTC。
[null,null,["最終更新日 2025-08-29 UTC。"],[],[],null,["# DateTime\n\n- [JSON representation](#SCHEMA_REPRESENTATION)\n\nRepresents civil time (or occasionally physical time).\n\nThis type can represent a civil time in one of a few possible ways:\n\n- When utcOffset is set and timeZone is unset: a civil time on a calendar day with a particular offset from UTC.\n- When timeZone is set and utcOffset is unset: a civil time on a calendar day in a particular time zone.\n- When neither timeZone nor utcOffset is set: a civil time on a calendar day in local time.\n\nThe date is relative to the Proleptic Gregorian Calendar.\n\nIf year, month, or day are 0, the DateTime is considered not to have a specific year, month, or day respectively.\n\nThis type may also be used to represent a physical time if all the date and time fields are set and either case of the `time_offset` oneof is set. Consider using `Timestamp` message for physical time instead. If your use case also would like to store the user's timezone, that can be done in another field.\n\nThis type is more flexible than some applications may want. Make sure to document and validate your application's limitations.\n\n| JSON representation |\n|--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|\n| ``` { \"year\": integer, \"month\": integer, \"day\": integer, \"hours\": integer, \"minutes\": integer, \"seconds\": integer, \"nanos\": integer, // Union field `time_offset` can be only one of the following: \"utcOffset\": string, \"timeZone\": { object (/maps/documentation/weather/reference/rest/v1/TimeZone) } // End of list of possible types for union field `time_offset`. } ``` |\n\n| Fields ||\n|---------------|------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|\n| `year` | `integer` Optional. Year of date. Must be from 1 to 9999, or 0 if specifying a datetime without a year. |\n| `month` | `integer` Optional. Month of year. Must be from 1 to 12, or 0 if specifying a datetime without a month. |\n| `day` | `integer` Optional. Day of month. Must be from 1 to 31 and valid for the year and month, or 0 if specifying a datetime without a day. |\n| `hours` | `integer` Optional. Hours of day in 24 hour format. Should be from 0 to 23, defaults to 0 (midnight). An API may choose to allow the value \"24:00:00\" for scenarios like business closing time. |\n| `minutes` | `integer` Optional. Minutes of hour of day. Must be from 0 to 59, defaults to 0. |\n| `seconds` | `integer` Optional. Seconds of minutes of the time. Must normally be from 0 to 59, defaults to 0. An API may allow the value 60 if it allows leap-seconds. |\n| `nanos` | `integer` Optional. Fractions of seconds in nanoseconds. Must be from 0 to 999,999,999, defaults to 0. |\n| Union field `time_offset`. Optional. Specifies either the UTC offset or the time zone of the DateTime. Choose carefully between them, considering that time zone data may change in the future (for example, a country modifies their DST start/end dates, and future DateTimes in the affected range had already been stored). If omitted, the DateTime is considered to be in local time. `time_offset` can be only one of the following: ||\n| `utc``Offset` | `string (`[Duration](https://protobuf.dev/reference/protobuf/google.protobuf/#duration)` format)` UTC offset. Must be whole seconds, between -18 hours and +18 hours. For example, a UTC offset of -4:00 would be represented as { seconds: -14400 }. A duration in seconds with up to nine fractional digits, ending with '`s`'. Example: `\"3.5s\"`. |\n| `time``Zone` | `object (`[TimeZone](/maps/documentation/weather/reference/rest/v1/TimeZone)`)` Time zone. |"]]