DateTime
קל לארגן דפים בעזרת אוספים
אפשר לשמור ולסווג תוכן על סמך ההעדפות שלך.
מייצג את השעה האזרחית (או לפעמים את השעה הפיזית).
הסוג הזה יכול לייצג זמן אזרחי באחת מכמה דרכים אפשריות:
- כשהערך של utcOffset מוגדר והערך של timeZone לא מוגדר: שעה אזרחית ביום קלנדרי עם הפרש מסוים מ-UTC.
- כשהערך של timeZone מוגדר והערך של utcOffset לא מוגדר: שעה אזרחית ביום קלנדרי באזור זמן מסוים.
- אם לא מוגדרים timeZone או utcOffset: שעה אזרחית ביום קלנדרי לפי השעון המקומי.
התאריך הוא ביחס ליומן הגרגוריאני הפרולפטי.
אם השנה, החודש או היום הם 0, המערכת מתייחסת ל-DateTime כאל תאריך ללא שנה, חודש או יום ספציפיים, בהתאמה.
אפשר להשתמש בסוג הזה גם כדי לייצג זמן פיזי אם כל שדות התאריך והשעה מוגדרים, וגם אם מוגדרת אחת מהאפשרויות של ה-oneof של time_offset
. במקום זאת, מומלץ להשתמש בהודעה 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 (חצות). יכול להיות ש-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 לפי הזמן המקומי. הערך של time_offset יכול להיות רק אחת מהאפשרויות הבאות: |
utcOffset |
string (Duration format)
קיזוז ל-UTC. הערך צריך להיות מספר שלם של שניות, בין 18 שעות לפני כן ל-18 שעות לאחר מכן. לדוגמה, אם ההיסט מ-UTC הוא -4:00, הוא יופיע כ-{ seconds: -14400 }. משך הזמן בשניות, עם עד תשע ספרות עשרוניות, שמסתיימים ב-'s '. דוגמה: "3.5s" .
|
timeZone |
object (TimeZone )
אזור הזמן.
|
אלא אם צוין אחרת, התוכן של דף זה הוא ברישיון Creative Commons Attribution 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. |"]]