- Как получить часовой пояс из android mobile?
- 8 ответов:
- Overview
- Introduction
- Before you begin
- Time Zone requests
- Required parameters
- location
- timestamp
- Optional parameters
- language
- Time Zone examples
- Get Started
- Sample request and response
- JavaScript
- Python
- Postman
- Start coding with our client libraries
- Authentication, quotas, pricing, and policies
- Authentication
- Quotas and pricing
- Policies
- Learn more
- Get Started
- Sample request and response
- JavaScript
- Python
- Postman
- Start coding with our client libraries
- Authentication, quotas, pricing, and policies
- Authentication
- Quotas and pricing
- Policies
- Learn more
Как получить часовой пояс из android mobile?
Я хочу получить часовой пояс с мобильного телефона Android при нажатии кнопки.
8 ответов:
вы пробовали использовать TimeZone.getDefault() :
большинство приложений будет использовать часовой пояс.getDefault() который возвращает часовой пояс на основе о часовом поясе, в котором выполняется программа.
часовой пояс GMT + 09: 30 Timezon id:: Австралия / Дарвин
он возвращает выбранный пользователем часовой пояс.
Мне нужно смещение это не только включало время экономии дневного света, но и как numerial. Вот код, который я использовал в случае, если кто-то ищет пример.
Я получаю ответ от «3.5» (3:30′) это то , что я ожидал бы в Тегеране, Иран зимой и «4.5» (4:30′) на лето .
мне также нужна была строка, чтобы я мог отправить ее на сервер, поэтому вам может не понадобиться последняя линия.
для получения currect часовой пояс:
согласно http://developer.android.com/reference/android/text/format/Time.html Вы должны использовать время.getCurrentTimezone () для получения текущего часового пояса устройства.
Самое Простое Решение С Простым Форматом Даты: SimpleDateFormat («ZZZZZ»):
часовой пояс часовой пояс = часовой пояс.getDefault(); часовой пояс.getID();
Источник
Overview
Introduction
The Time Zone API provides a simple interface to request the time zone for locations on the surface of the earth, as well as the time offset from UTC for each of those locations. You request the time zone information for a specific latitude/longitude pair and date. The API returns the name of that time zone, the time offset from UTC, and the daylight savings offset.
Before you begin
This document is intended for website and mobile developers who want to include time data on maps provided by one of the Google Maps Platform APIs. It provides an introduction to using the API and reference material on the available parameters.
Before you start developing with the Time Zone API, review the authentication requirements (you need an API key) and the API usage and billing information (you need to enable billing on your project).
Time Zone requests
Time Zone API requests are constructed as a URL string. The API returns time zone data for a point on the earth, specified by a latitude/longitude pair. Note that time zone data may not be available for locations over water, such as oceans or seas.
A Time Zone API request takes the following form:
where outputFormat may be either of the following values:
- json (recommended), indicates output in JavaScript Object Notation (JSON); or
- xml , indicates output in XML, wrapped within a node.
Note: URLs must be properly encoded to be valid and are limited to 8192 characters for all web services. Be aware of this limit when constructing your URLs. Note that different browsers, proxies, and servers may have different URL character limits as well.
Required parameters
location
A comma-separated latitude,longitude tuple, location=39.6034810,-119.6822510 , representing the location to look up.
timestamp
The desired time as seconds since midnight, January 1, 1970 UTC. The Time Zone API uses the timestamp to determine whether or not Daylight Savings should be applied, based on the time zone of the location .
Note that the API does not take historical time zones into account. That is, if you specify a past timestamp, the API does not take into account the possibility that the location was previously in a different time zone.
Optional parameters
language
The language in which to return results.
Time Zone examples
This section includes some sample queries that demonstrate features of the API.
The below query performs a time zone request for Nevada, USA. The timestamp is set to March 8th, 2012.
Источник
Get Started
The Time Zone API provides time offset data for locations on the surface of the earth. Request the time zone information for a specific latitude/longitude pair and date. The API returns the name of that time zone, the time offset from UTC, and the daylight savings offset.
Sample request and response
Access the Time Zone API through an HTTPS interface, with requests constructed as a URL string, using latitude/longitude coordinates to specify the location , a timestamp to specify the date, and your API key.
The below query performs a time zone request for Nevada, USA. The timestamp is set to March 8th, 2012.
JavaScript
Python
Postman
The OpenAPI specification is also available as a Postman collection.
You can test this by entering the URL into your web browser (be sure to replace YOUR_API_KEY with your actual API key). The response includes the time zone data for the specified location and date (timestamp) .
Below is a sample response, in JSON:
Start coding with our client libraries
Client libraries make developing with the Google Maps web service APIs easier by providing simple, native implementations of common tasks such as authentication, request throttling and automatic retry. The Time Zone API is available in the Java Client, Python Client, Go Client and Node.js Client for Google Maps Services.
Authentication, quotas, pricing, and policies
Authentication
To use the Time Zone API, you must first enable the API and obtain the proper authentication credentials. For more information, see Get Started with Google Maps Platform.
Quotas and pricing
Review the usage and billing page for details on the quotas and pricing set for the Time Zone API.
Policies
Use of the Time Zone API must be in accordance with the API policies.
Learn more
In the Time Zone API, you can also set a language parameter to return results in languages other than the default of English. See the Time Zone API Developer Guide for more examples and other details.
The Time Zone API Developer Guide is intended for website and mobile developers who want to include time data on maps provided by one of the Google Maps Platform APIs. It provides an introduction to using the API and reference material on the available parameters.
Except as otherwise noted, the content of this page is licensed under the Creative Commons Attribution 4.0 License, and code samples are licensed under the Apache 2.0 License. For details, see the Google Developers Site Policies. Java is a registered trademark of Oracle and/or its affiliates.
Источник
Get Started
The Time Zone API provides time offset data for locations on the surface of the earth. Request the time zone information for a specific latitude/longitude pair and date. The API returns the name of that time zone, the time offset from UTC, and the daylight savings offset.
Sample request and response
Access the Time Zone API through an HTTPS interface, with requests constructed as a URL string, using latitude/longitude coordinates to specify the location , a timestamp to specify the date, and your API key.
The below query performs a time zone request for Nevada, USA. The timestamp is set to March 8th, 2012.
JavaScript
Python
Postman
The OpenAPI specification is also available as a Postman collection.
You can test this by entering the URL into your web browser (be sure to replace YOUR_API_KEY with your actual API key). The response includes the time zone data for the specified location and date (timestamp) .
Below is a sample response, in JSON:
Start coding with our client libraries
Client libraries make developing with the Google Maps web service APIs easier by providing simple, native implementations of common tasks such as authentication, request throttling and automatic retry. The Time Zone API is available in the Java Client, Python Client, Go Client and Node.js Client for Google Maps Services.
Authentication, quotas, pricing, and policies
Authentication
To use the Time Zone API, you must first enable the API and obtain the proper authentication credentials. For more information, see Get Started with Google Maps Platform.
Quotas and pricing
Review the usage and billing page for details on the quotas and pricing set for the Time Zone API.
Policies
Use of the Time Zone API must be in accordance with the API policies.
Learn more
In the Time Zone API, you can also set a language parameter to return results in languages other than the default of English. See the Time Zone API Developer Guide for more examples and other details.
The Time Zone API Developer Guide is intended for website and mobile developers who want to include time data on maps provided by one of the Google Maps Platform APIs. It provides an introduction to using the API and reference material on the available parameters.
Except as otherwise noted, the content of this page is licensed under the Creative Commons Attribution 4.0 License, and code samples are licensed under the Apache 2.0 License. For details, see the Google Developers Site Policies. Java is a registered trademark of Oracle and/or its affiliates.
Источник