timezone

Convert Date by TimeZone

牧云@^-^@ 提交于 2020-01-21 19:43:26
问题 In that code above I want to transform a Date by the TimeZone of Server (GMT-02:00) to TimeZone from my Device (GMT-03:00). But I Always have the same Date of the server. What I doing wrong? TimeZone timeZoneServer = TimeZone.getTimeZone(timeZoneServerString); Long time = new Long(Long.valueOf(timeInMilis)); Calendar calendarDateServer = Calendar.getInstance(timeZoneServer); calendarDateServer.setTimeInMillis(time); long miliServer = calendarDateServer.getTimeInMillis(); TimeZone timeZoneMeu

Convert Date by TimeZone

梦想的初衷 提交于 2020-01-21 19:43:07
问题 In that code above I want to transform a Date by the TimeZone of Server (GMT-02:00) to TimeZone from my Device (GMT-03:00). But I Always have the same Date of the server. What I doing wrong? TimeZone timeZoneServer = TimeZone.getTimeZone(timeZoneServerString); Long time = new Long(Long.valueOf(timeInMilis)); Calendar calendarDateServer = Calendar.getInstance(timeZoneServer); calendarDateServer.setTimeInMillis(time); long miliServer = calendarDateServer.getTimeInMillis(); TimeZone timeZoneMeu

PostgreSQL SQLalchemy and timestamp with time zone, why is incognito different from normal?

谁说我不能喝 提交于 2020-01-17 15:39:09
问题 I am using flask sqlalchemy and postgreSQL and I have issues with the displayed datetimes, while investigating this issue I found an other weird thing: Creating a DB entry in incognito mode (chrome browser tab) gives a different/wrong time. EDIT: It has nothing to do with incognito mode, both cases happen in normal mode aswell. I have not figured out yet why. This is the code: I changed the default time zone of my database: ALTER DATABASE postgres SET timezone TO 'Europe/Berlin'; the model:

Convert String to date of specific timezone

谁都会走 提交于 2020-01-17 14:00:29
问题 I need to convert a string to date in a specific timezone. Eg. from = "June 13, 2015" Date.strptime(from,"%b %d, %Y") #=> Sat, 13 Jun 2015 Date.strptime(from.strip,"%b %d, %Y").in_time_zone("America/Chicago") #=> Sat, 13 Jun 2015 00:00:00 CDT -05:00 which is ActiveSupport::TimeWithZone format Date.strptime(from,"%b %d, %Y").in_time_zone("America/Chicago").to_date #=>Sat, 13 Jun 2015 which is in UTC Date class I need the final date in America/Chicago timezone. How can I achieve that? I need to

Python datetime.now() with timezone

試著忘記壹切 提交于 2020-01-17 11:13:00
问题 I have a timezone which is float (for example 4.0). I want to construct datetime with given timezone. I tried this, datetime.now(timezone) but it throws TypeError: tzinfo argument must be None or of a tzinfo subclass, not type 'float' So I wonder how can I make tzinfo from float? 回答1: If you are using Python 3.2 or newer, you need to create a datetime.timezone() object; it takes an offset as a datetime.timedelta(): offset = timezone(timedelta(hours=timezone) datetime.now(offset)) For earlier

Python datetime.now() with timezone

99封情书 提交于 2020-01-17 11:12:05
问题 I have a timezone which is float (for example 4.0). I want to construct datetime with given timezone. I tried this, datetime.now(timezone) but it throws TypeError: tzinfo argument must be None or of a tzinfo subclass, not type 'float' So I wonder how can I make tzinfo from float? 回答1: If you are using Python 3.2 or newer, you need to create a datetime.timezone() object; it takes an offset as a datetime.timedelta(): offset = timezone(timedelta(hours=timezone) datetime.now(offset)) For earlier

Converting timezone for date faster using java

瘦欲@ 提交于 2020-01-17 05:19:13
问题 I have written this method for converting a date time zone. How do i reduce the execution time of this method further. public static Timestamp convertTimeZone(final Timestamp fromDate, final TimeZone fromTZ, final TimeZone toTZ ){ Long timeInDate = fromDate.getTime() ; int fromOffset = fromTZ.getOffset(timeInDate); int toOffset = toTZ.getOffset(timeInDate); Timestamp dateStamp = new Timestamp(fromDate.getTime()); if (fromOffset >= 0){ int diff = 0; if (toOffset > 0){ diff = (fromOffset -

Convert Time Zone + format in Python from Twitter API

孤者浪人 提交于 2020-01-17 04:21:49
问题 In Python, with TwitterSearch, I'm able to get the timestamp of the tweet in UTC time, in the following format : Thu Mar 19 12:37:15 +0000 2015 However, I would like to obtain it automatically in the EST timezone (UTC - 4), in this format : 2015-03-19 08:37:15 Here is a sample of my code. What should I change in it for an automatic conversion? for tweet in ts.search_tweets_iterable(tso): lat = None long = None user = tweet['user']['screen_name'] user_creation = tweet['user']['created_at']

Convert Time Zone + format in Python from Twitter API

断了今生、忘了曾经 提交于 2020-01-17 04:21:14
问题 In Python, with TwitterSearch, I'm able to get the timestamp of the tweet in UTC time, in the following format : Thu Mar 19 12:37:15 +0000 2015 However, I would like to obtain it automatically in the EST timezone (UTC - 4), in this format : 2015-03-19 08:37:15 Here is a sample of my code. What should I change in it for an automatic conversion? for tweet in ts.search_tweets_iterable(tso): lat = None long = None user = tweet['user']['screen_name'] user_creation = tweet['user']['created_at']

How to get the unique TimeZone Display name in all the android devices?

ε祈祈猫儿з 提交于 2020-01-17 04:19:09
问题 I have used the below code to get the android mobile timezone display name. String mobileTimeZone = Calendar.getInstance().getTimeZone() .getDisplayName(false, TimeZone.SHORT); But running the same code in two different devices returns two different values as follows, In Sony xperia Z1, it returns IST . In Samsung Galaxy S3, it returns GMT+05.30 . How to get the unique value like IST or ET in all the devices. Please help me on to solve this issue. 回答1: I see the same GMT+5:30 on my Huawei