timezone-offset

OffsetDateTime - print offset instead of Z

三世轮回 提交于 2020-12-10 04:08:52
问题 I have this code: String date = "2019-04-22T00:00:00+02:00"; OffsetDateTime odt = OffsetDateTime .parse(date, DateTimeFormatter.ISO_OFFSET_DATE_TIME) .withOffsetSameInstant(ZoneOffset.of("+00:00")); System.out.println(odt); This print: 2019-04-21T22:00Z How can I print 2019-04-21T22:00+00:00 ? With offset instead of Z . 回答1: None of the static DateTimeFormatter s do this in the standard library. They either default to Z or GMT . To achieve +00:00 for no offset, you will have to build your own

OffsetDateTime - print offset instead of Z

南笙酒味 提交于 2020-12-10 04:07:58
问题 I have this code: String date = "2019-04-22T00:00:00+02:00"; OffsetDateTime odt = OffsetDateTime .parse(date, DateTimeFormatter.ISO_OFFSET_DATE_TIME) .withOffsetSameInstant(ZoneOffset.of("+00:00")); System.out.println(odt); This print: 2019-04-21T22:00Z How can I print 2019-04-21T22:00+00:00 ? With offset instead of Z . 回答1: None of the static DateTimeFormatter s do this in the standard library. They either default to Z or GMT . To achieve +00:00 for no offset, you will have to build your own

get client's GMT offset in javascript

て烟熏妆下的殇ゞ 提交于 2020-07-15 08:53:46
问题 how can I get the GMT offset in javascript of the client? new Date().getTimezoneOffset(); returns the difference from UTC. Is there a way I can calculate the GMT offset from that? By GMT offset, I mean as in -5 for eastern standard time. 回答1: new Date().getTimezoneOffset(); returns the difference from UTC. Is there a way I can calculate the GMT offset from that? The timezone offset is the difference from GMT in minutes (see ECMA-262 §15.9.5.26). The sign is the reverse of ISO 8601, but it's

Fetching/selecting bottom N elements is messing up the value of time stamp in result set (because of time zone I think)

徘徊边缘 提交于 2020-06-17 09:34:51
问题 I spent almost a day trying to fetch bottom 10 rows from a table that has few hundred thousand rows in multiple ways . But timestamp in result set is always messed up by 7 hours (that is the time difference between UTC and my local) Schema CREATE TABLE IF NOT EXISTS xyz( id timestamp NOT NULL, name varchar(40) NOT NULL, PRIMARY KEY (id,name ) ); Bottom 10 entries in db after running select * from xyz order by id desc limit 10; 2020-05-12 12:00:00+00 2020-05-12 12:00:00+00 2020-05-12 11:59:00

Fetching/selecting bottom N elements is messing up the value of time stamp in result set (because of time zone I think)

蹲街弑〆低调 提交于 2020-06-17 09:34:25
问题 I spent almost a day trying to fetch bottom 10 rows from a table that has few hundred thousand rows in multiple ways . But timestamp in result set is always messed up by 7 hours (that is the time difference between UTC and my local) Schema CREATE TABLE IF NOT EXISTS xyz( id timestamp NOT NULL, name varchar(40) NOT NULL, PRIMARY KEY (id,name ) ); Bottom 10 entries in db after running select * from xyz order by id desc limit 10; 2020-05-12 12:00:00+00 2020-05-12 12:00:00+00 2020-05-12 11:59:00

How to get timezone by utc offset?

为君一笑 提交于 2020-06-17 03:03:33
问题 I have the UTC offset -05:00, I want to get timezone names by offset. ZoneOffset offset = ZoneOffset.of("-05:00"); System.out.println(offset.getId()); //prints -05:00 I want to get the result like this : America/Chicago America/Eirunepe Etc/GMT+5 Mexico/General ... I want time zones that are at offset -05:00 right now (not those that may be at another time of year). 回答1: Yes you can do it, check this out. final List<ZoneId> timeZoneByUtc = ZoneId.getAvailableZoneIds().stream().map(ZoneId::of)

How to check if open to close time has elapse using timezone in javascript

感情迁移 提交于 2020-05-31 04:57:06
问题 I have this below functionin my webapp to check if from OPEN to CLOSE time has elapse using a country timezone and it's working fine. Am trying to optimize my website, so my question is how can i make a function like this in javascript without the use of moment timezone? The moment timezone file is large and this is the only usage of it on my website. function isOpen(openTime, closeTime, timezone) { // handle special case if (openTime === "24HR") { return "open"; } // get the current date and

Adding Time Offset in Swift

二次信任 提交于 2020-04-05 11:58:53
问题 I have a bunch of different show times in a database and want to display the correct time based on the users time zone by creating an offset. I'm getting the users time zone offset from GMT and converting that to hours first. NSTimeZone.localTimeZone().secondsFromGMT / 60 / 60 Then I need to find a way to add the hours to the date object.. that is where I/m struggling. let formatter = NSDateFormatter() formatter.dateFormat = "HH:mm" let date = formatter.dateFromString(timeAsString) println(