DateTime
Mantieni tutto organizzato con le raccolte
Salva e classifica i contenuti in base alle tue preferenze.
Rappresenta l'ora civile (o occasionalmente l'ora fisica).
Questo tipo può rappresentare un orario civile in uno dei seguenti modi:
- Quando utcOffset è impostato e timeZone non è impostato: un'ora civile in un giorno di calendario con una determinata differenza rispetto a UTC.
- Quando timeZone è impostato e utcOffset non è impostato: un'ora civile in un giorno di calendario in un determinato fuso orario.
- Se non sono impostati né timeZone né utcOffset: un'ora civile in un giorno di calendario in ora locale.
La data è relativa al calendario gregoriano prolettico.
Se anno, mese o giorno sono pari a 0, l'oggetto DateTime è considerato non avere rispettivamente un anno, un mese o un giorno specifici.
Questo tipo può essere utilizzato anche per rappresentare un'ora fisica se tutti i campi della data e dell'ora sono impostati e una delle due opzioni di time_offset
oneof è impostata. Prendi in considerazione l'utilizzo del messaggio Timestamp
per l'ora fisica. Se il tuo caso d'uso vuole memorizzare anche il fuso orario dell'utente, puoi farlo in un altro campo.
Questo tipo è più flessibile di quanto potrebbe essere richiesto da alcune applicazioni. Assicurati di documentare e convalidare le limitazioni della tua applicazione.
Rappresentazione 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 .
} |
Campi |
year |
integer
Facoltativo. Anno della data. Deve essere compreso tra 1 e 9999 oppure 0 se viene specificato un timestamp senza anno.
|
month |
integer
Facoltativo. Mese dell'anno. Deve essere compreso tra 1 e 12 oppure 0 se viene specificato un valore data/ora senza un mese.
|
day |
integer
Facoltativo. Giorno del mese. Deve essere compreso tra 1 e 31 e valido per l'anno e il mese oppure 0 se viene specificato un valore data/ora senza un giorno.
|
hours |
integer
Facoltativo. Ore del giorno nel formato 24 ore. Deve essere compreso tra 0 e 23, il valore predefinito è 0 (mezzanotte). Un'API potrebbe scegliere di consentire il valore "24:00:00" per scenari come l'orario di chiusura dell'attività.
|
minutes |
integer
Facoltativo. Minuti dell'ora del giorno. Deve essere compreso tra 0 e 59. Il valore predefinito è 0.
|
seconds |
integer
Facoltativo. Secondi di minuti del tempo. Deve normalmente essere compreso tra 0 e 59, il valore predefinito è 0. Un'API potrebbe consentire il valore 60 se consente i secondi intercalari.
|
nanos |
integer
Facoltativo. Frazioni di secondo in nanosecondi. Deve essere compreso tra 0 e 999.999.999; il valore predefinito è 0.
|
Campo unione time_offset . Facoltativo. Specifica l'offset UTC o il fuso orario di DateTime. Scegli con attenzione tra le due opzioni, tenendo presente che i dati relativi al fuso orario potrebbero cambiare in futuro (ad esempio, un paese modifica le date di inizio/fine del DST e le date e ore future nell'intervallo interessato sono già state memorizzate). Se omesso, la data e l'ora sono considerate in ora locale. time_offset può essere solo uno dei seguenti: |
utcOffset |
string (Duration format)
Scarto da UTC. Devono essere secondi interi, compresi tra -18 ore e +18 ore. Ad esempio, un offset UTC di -4:00 viene rappresentato come { seconds: -14400 }. Una durata in secondi con un massimo di nove cifre frazionarie, che termina con "s ". Esempio: "3.5s" .
|
timeZone |
object (TimeZone )
Fuso orario.
|
Salvo quando diversamente specificato, i contenuti di questa pagina sono concessi in base alla licenza Creative Commons Attribution 4.0, mentre gli esempi di codice sono concessi in base alla licenza Apache 2.0. Per ulteriori dettagli, consulta le norme del sito di Google Developers. Java è un marchio registrato di Oracle e/o delle sue consociate.
Ultimo aggiornamento 2025-08-29 UTC.
[null,null,["Ultimo aggiornamento 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. |"]]