timezone

DateFormat pattern “yyyy-MM-dd'T'HH:mm:ss.SSS'Z'” in Gson

泪湿孤枕 提交于 2019-12-21 03:48:33
问题 I have two field like below ( pay attention that the first field has milliseconds section ): { "updateTime":"2011-11-02T02:50:12.208Z", "deliverTime":"1899-12-31T16:00:00Z" } I want to deserialize the Json string to an object with Gson, so I get a Gson instance: GsonBuilder gb = new GsonBuilder(); gb.setDateFormat("yyyy-MM-dd'T'HH:mm:ss.SSS'Z'"); gson = gb.create(); The first field is deserialized to Java date type: 2011-11-02 02:50:12.208 (looks like ignored the time zone section-‘Z’, that's

How to use tzutc()

巧了我就是萌 提交于 2019-12-21 03:29:08
问题 What am I missing, how do I get this function to work? import dateutil.parser import datetime my_date = datetime.datetime(2000, 1, 1, 0, 0, 0, 000000, tzinfo=tzutc()) print(my_date) Gives me the error: NameError: name 'tzutc' is not defined 回答1: You did not import it: from dateutil.tz import tzutc 来源: https://stackoverflow.com/questions/44625803/how-to-use-tzutc

How to create a new DateTime object in a specific time zone (preferably the default time zone of my app, not UTC)?

ⅰ亾dé卋堺 提交于 2019-12-21 03:09:09
问题 I have set the time zone in /config/application.rb , and I expect all times generated in my app to be in this time zone by default, yet when I create a new DateTime object (using .new ), it creates it in GMT . How can I get it to be in my app's time zone? /config/application.rb config.time_zone = 'Pacific Time (US & Canada)' irb irb> DateTime.now => Wed, 11 Jul 2012 19:04:56 -0700 irb> mydate = DateTime.new(2012, 07, 11, 20, 10, 0) => Wed, 11 Jul 2012 20:10:00 +0000 # GMT, but I want PDT

Same datetime across timezones in browser - on a booking engine

假装没事ソ 提交于 2019-12-21 02:41:23
问题 I'm looking for the best practice/solution to book a service internationally, using same time in any browser. I don't quite get the logic (and dug around here too). Use case user in Brussels booking lets say a haircut service based in Singapore - he is flying there in a week. He picks 14:00 in the browser datetime control. The browser is, however, set to +1 UTC. SG haircut stylist should see the time in his agenda as 14:00 SG time. the barber shop owner is traveling at Dubai, and he wants to

How to get timezone from properties in CultureInfo

梦想与她 提交于 2019-12-20 18:44:32
问题 I have a string, which contains a timestamp ( yyyy-mm-dd hh:mm:ss ) . I can create a CultureInfo object based on other information I get. Therefore I know which country the timestamp is in. The timestamp is not in UTC/GMT. Say the timestamp is from Indonesia ( new CultureInfo("id-ID") ) , meaning the string was created by code below or similar. DateTime.Now.ToString("yyyy-MM-dd hh:mm:ss"); That means the string contains the local time in Indonesia. I know my timezone, but I don't know how to

iOS - How to get raw offset for timezone?

怎甘沉沦 提交于 2019-12-20 16:35:14
问题 How do I get the raw offset in milliseconds for Coordinated Universal Time in iOS programmatically? 回答1: NSInteger millisecondsFromGMT = 1000 * [[NSTimeZone localTimeZone] secondsFromGMT]; In Swift 3 and Swift 4: let millisecondsFromGmt = 1000 * TimeZone.autoupdatingCurrent.secondsFromGMT() 回答2: Please see answer to my question: https://stackoverflow.com/a/31988549/3004003 It seems to be more precise regarding expression raw offset , because "raw" actually should mean "without DST at all",

Difference between new Date() and Calendar date

旧巷老猫 提交于 2019-12-20 12:43:22
问题 What is the difference between the two dates below in practice? Date date = new Date(); Date date = Calendar.getInstance().getTime(); What I understand is that new Date() is a UTC/GMT based date while calendar's getTime() is based on TimeZone & System time. Am I right? Do I miss something still? Moreover, if my above understanding is correct, can I say that the end results of the following two functions are exactly the same ? 1. public String getDate1(){ SimpleDateFormat sdf = new

Getting Time Zone from Lat Long Coordinates? [duplicate]

梦想的初衷 提交于 2019-12-20 11:55:16
问题 This question already has answers here : How to get a time zone from a location using latitude and longitude coordinates? (15 answers) Closed 12 months ago . I am trying to get the time zones for latitude and longitude coordinates but am having a few problems The mistakes are probably very basic I have a table in a database with around 600 rows. Each row contains a lat long coordinate for somewhere in the world I want to feed these co-ordinates into a function and then retrieve the time zone.

Modifying timezone of a POSIXct object without changing the display

北慕城南 提交于 2019-12-20 10:39:32
问题 I have a POSIXct object and would like to change it's tz attribute WITHOUT R to interpret it (interpret it would mean to change how the datetime is displayed on the screen). Some background: I am using the fasttime package from S.Urbanek, which take strings and cast it to POSIXct very quickly. Problem is that the string should represent a datetime in "GMT" and it's not the case of my data. I end up with a POSIXct object with tz=GMT , in reality it is tz=GMT+1 , if I change the timezone with

The server time zone value 'CEST' is unrecognized

老子叫甜甜 提交于 2019-12-20 09:57:41
问题 I am using hibernate (Hibernate Maven 5.2.15.Final, Mysql-connector Maven 8.0.9-rc) whith mysql 5.7 on lampp environment on linux so. I am in Italy (Central European Summer Time) and once March 25, occurs follow error on connection db: The server time zone value 'CEST' is unrecognized or represents more than one time zone. You must configure either the server or JDBC driver (via the serverTimezone configuration property) to use a more specifc time zone value if you want to utilize time zone