utc

SimpleDateFormat ignores “XXX” if timezone is set to “UTC”

↘锁芯ラ 提交于 2019-12-04 07:04:42
I am trying to output the current datetime as UTC in the following format: 2016-01-11T14:08:42+00:00 final SimpleDateFormat formatter = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ssXXX"); formatter.setTimeZone(TimeZone.getTimeZone("UTC")); final String dateString = formatter.format(new Date()); "dateString" should now contain "2016-01-11T14:08:42+00:00" but it contains "2016-01-11T14:08:42Z". Without the "UTC" timezone setting I get the right format but - of course - in my specific timezone... Any ideas? See the documentation for SimpleDateFormat : For formatting [using an ISO 8601 Time zone],

ZonedDateTime to UTC with offset applied?

孤人 提交于 2019-12-04 05:56:09
I am using Java 8 This is what my ZonedDateTime looks like 2013-07-10T02:52:49+12:00 I get this value as z1.format(DateTimeFormatter.ISO_OFFSET_DATE_TIME) where z1 is a ZonedDateTime . I wanted to convert this value as 2013-07-10T14:52:49 How can I do that? Is this what you want? This converts your ZonedDateTime to a LocalDateTime with a given ZoneId by converting your ZonedDateTime to an Instant before. LocalDateTime localDateTime = LocalDateTime.ofInstant(z1.toInstant(), ZoneOffset.UTC); Or maybe you want the users system-timezone instead of hardcoded UTC: LocalDateTime localDateTime =

Convert UTC string to TDatetime in Delphi

强颜欢笑 提交于 2019-12-04 05:41:23
var tm : string; dt : tdatetime; tm := '2009-08-21T09:11:21Z'; dt := ? I know I can parse it manually but I wonder if there is any built-in function or Win32 API function to do this ? delphi_hangover I don't know why there are so many people shooting their mouth off when they don't know what they are talking about? I have to do this menial work; Is it a RAD tool? I sometimes find Delphi has a real superb architecture, though. procedure setISOtoDateTime(strDT: string); var // Delphi settings save vars ShortDF, ShortTF : string; TS, DS : char; // conversion vars dd, tt, ddtt: TDateTime; begin //

Find correct time on iOS device

人走茶凉 提交于 2019-12-04 05:29:32
问题 I want to find out correct time on iOS devices even though user have set wrong time manually. In the setting->General->Date & Time there is option of Set Automatically if that option is uncheck by the user then how can i find the correct time programmatically. 回答1: Use NTP protocol for getting a current time or serve a time from your server and get it on application launch. Apple doesn't provide by default any way to get time from NTP unfortunately and all time related function are using

Should timestamps always use UTC?

南笙酒味 提交于 2019-12-04 04:58:26
Should timestamps always use UTC (as in 2012-06-14T10:32:11+00:00 ) and not local time (as in 2012-06-14T06:32:11-04:00 for New York)? References Although not a WordPress question, I believe it'll be a strong example -- the WordPress core, themes and plugins developed by the core developers, if outputting timestamp somewhere, always seem to use something like get_the_date('c'); or get_the_modified_date('c'); -- which always output timestamp in UTC, as in 2012-06-14T10:32:11 +00:00 . I just came across this answer which simply states that "Time stamps use UTC." The question Should timestamps be

How to convert UTC datetime column to local time in datagridview?

牧云@^-^@ 提交于 2019-12-04 04:26:45
问题 I am doing work on a new logging database that I have decided to use UTC datetime to store all datetime values since our company spans timezones and multiple sources and timezones are logging events. That is working great. However the problem that I cannot get my head around is formatting the datetimes in my datagridview for my user application. Our applications use mostly LINQ to SQL to manipulate our data from generic SQL CRUD calls, so I am hoping I can mask/format the DGV to get the

mktime returns wrong timestamp (off by a whole month)

自作多情 提交于 2019-12-04 04:08:43
问题 I use mktime to create a unix timestamp from my current local time: #include <time.h> int _tmain(int argc, _TCHAR* argv[]) { struct tm info; // 16.05.2014 info.tm_mday = 16; info.tm_mon = 5; info.tm_year = 114; // Years since 1900 // 08:00:00 Uhr info.tm_hour = 8; info.tm_min = 0; info.tm_sec = 0; // Convert to Unix timestamp info.tm_isdst = -1; time_t timestamp = mktime(&info); printf("Timestamp: %i", timestamp); } This gives me: 1402898400 When converting this back to a human readable time

ActiveRecord is not aware of timezones?

久未见 提交于 2019-12-04 03:44:59
问题 I have one question regarding to time zone I have done the following yet, my activerecord is not still matching with my timezone when I do following query def stock_by_date(date) UserStock.where("date(created_at) = ? and user_id = ? ", date , current_user.id) end I did the following in side my application.rb config.active_record.default_timezone = :utc config.active_record.time_zone_aware_attributes = true config.beginning_of_week = :sunday config.active_record.time_zone_aware_types = [

How to change a MySQL database to UTC?

。_饼干妹妹 提交于 2019-12-04 03:02:44
I'm on Windows 7 and I'm a bit new to this database stuff. I tried searching on Google for how to change the timezone from my system to UTC but the documents are somewhat advanced and I'm not too sure how to change this field. In your my.ini file, under the [mysqld] section, add the following line: default-time-zone = '+00:00' Restart the server. You could also set it at runtime from the command line with mysql> SET GLOBAL time_zone = '+00:00'; The documentation from MySql 来源: https://stackoverflow.com/questions/5359495/how-to-change-a-mysql-database-to-utc

Why does Java's java.time.format.DateTimeFormatter#format(LocalDateTime) add a year?

╄→尐↘猪︶ㄣ 提交于 2019-12-04 02:27:40
问题 This is the code: LocalDateTime localDateTime = LocalDateTime.ofInstant(Instant.ofEpochMilli(1451438792953L), ZoneId.of("UTC")); DateTimeFormatter dateTimeFormatter = DateTimeFormatter.ofPattern("YYYY-MM-dd'T'HH:mm:ss.SSS'Z'"); String output = dateTimeFormatter.format(localDateTime); This is the value of localDateTime : 2015-12-30T01:26:32.953 This is the value of output : 2016-12-30T01:26:32.953Z Why does it add a year? In java.time.temporal.WeekFields there are a couple of methods with a