DateTime
Zadbaj o dobrą organizację dzięki kolekcji
Zapisuj i kategoryzuj treści zgodnie ze swoimi preferencjami.
Reprezentuje czas urzędowy (lub czas fizyczny).
Ten typ może reprezentować czas cywilny na jeden z kilku możliwych sposobów:
- Jeśli parametr utcOffset jest ustawiony, a parametr timeZone nie jest ustawiony: czas cywilny w danym dniu kalendarzowym z określonym przesunięciem względem czasu UTC.
- Gdy parametr timeZone jest ustawiony, a parametr utcOffset nie jest ustawiony: czas cywilny w danym dniu kalendarzowym w danej strefie czasowej.
- Jeśli ani timeZone, ani utcOffset nie są ustawione: czas cywilny w dniu kalendarzowym w czasie lokalnym.
Data jest obliczana na podstawie przedłużonego kalendarza gregoriańskiego.
Jeśli rok, miesiąc lub dzień mają wartość 0, obiekt DateTime jest uważany za niemający określonego roku, miesiąca ani dnia.
Ten typ może też służyć do reprezentowania czasu fizycznego, jeśli wszystkie pola daty i godziny są ustawione, a jeden z wariantów time_offset
jest ustawiony. Zamiast tego możesz użyć wiadomości Timestamp
, aby określić czas fizyczny. Jeśli w Twoim przypadku chcesz też przechowywać strefę czasową użytkownika, możesz to zrobić w innym polu.
Ten typ jest bardziej elastyczny niż w przypadku niektórych aplikacji. Udokumentuj i sprawdź ograniczenia aplikacji.
Zapis 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 .
} |
Pola |
year |
integer
Opcjonalnie: Rok daty. Musi być w zakresie od 1 do 9999 lub 0, jeśli określasz datę i godzinę bez roku.
|
month |
integer
Opcjonalnie: Miesiąc roku. Wartość musi mieścić się w przedziale od 1 do 12 lub 0, jeśli podajesz datę i godzinę bez miesiąca.
|
day |
integer
Opcjonalnie: Dzień miesiąca. Musi być liczbą z zakresu 1–31 i musi być prawidłową wartością dla roku i miesiąca lub 0, jeśli podajesz datę i godzinę bez dnia.
|
hours |
integer
Opcjonalnie: Godziny w formacie 24-godzinnym. Wartość powinna mieścić się w zakresie od 0 do 23. Domyślnie jest ustawiana na 0 (północ). Interfejs API może zezwolić na wartość „24:00:00” w przypadku scenariuszy takich jak godziny zamknięcia firmy.
|
minutes |
integer
Opcjonalnie: Minuty w godzinie. Wartość musi mieścić się w zakresie od 0 do 59, domyślnie jest to 0.
|
seconds |
integer
Opcjonalnie: sekundy, Wartość musi mieścić się w zakresie od 0 do 59, domyślnie jest to 0. Interfejs API może zezwalać na wartość 60, jeśli zezwala na sekundy przestępne.
|
nanos |
integer
Opcjonalnie: Ułamki sekundy w nanosekundach. Musi mieścić się w przedziale od 0 do 999 999 999, a domyślnie przyjmuje wartość 0.
|
Pole unii time_offset . Opcjonalnie: Określa przesunięcie UTC lub strefę czasową DateTime. Wybierz je uważnie, pamiętając, że dane strefy czasowej mogą się w przyszłości zmienić (np. kraj zmodyfikuje daty rozpoczęcia i zakończenia czasu letniego, a dane DateTime z przyszłości w zakresie, którego dotyczy zmiana, zostały już zapisane). Jeśli nie podasz tej wartości, DateTime jest uważany za czas lokalny. time_offset może być tylko jednym z tych elementów: |
utcOffset |
string (Duration format)
przesunięcie UTC. Musi być podana w całych sekundach w zakresie od -18 do +18 godzin. Na przykład przesunięcie UTC o -4:00 będzie przedstawione jako { seconds: -14400 }. Czas w sekundach z maksymalnie 9 miejscami po przecinku, zakończony literą „s ”. Przykład: "3.5s" .
|
timeZone |
object (TimeZone )
Strefa czasowa.
|
O ile nie stwierdzono inaczej, treść tej strony jest objęta licencją Creative Commons – uznanie autorstwa 4.0, a fragmenty kodu są dostępne na licencji Apache 2.0. Szczegółowe informacje na ten temat zawierają zasady dotyczące witryny Google Developers. Java jest zastrzeżonym znakiem towarowym firmy Oracle i jej podmiotów stowarzyszonych.
Ostatnia aktualizacja: 2025-08-29 UTC.
[null,null,["Ostatnia aktualizacja: 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. |"]]