timezone

user datetime setting as GMT, how to convert date to their localized setting?

旧街凉风 提交于 2019-12-10 23:57:02
问题 In my users setting I have a dropdown with all the GMT dates for the user to select. In c#, how would I convert a datetime stored in the database to their GMT time? The time stored in the database is the servers time. 回答1: For .NET 3.5+, you can store the system time zone identifier with the user (you can get those from TimeZoneInfo.GetSystemTimeZones ) and use TimeZoneInfo to convert between time zones: // In a User class that has a string timeZoneId field (for example) public DateTime

UTC converted to Central Europe Standard Time is 2 hours in front not 1

情到浓时终转凉″ 提交于 2019-12-10 23:55:31
问题 I'm trying to understand why my date is wrong: DateTime databaseUtcTime = new DateTime(2016, 8, 15, 10, 20, 0, DateTimeKind.Utc); var timeZone = TimeZoneInfo.FindSystemTimeZoneById("Central Europe Standard Time"); var testDateTime = TimeZoneInfo.ConvertTimeFromUtc(databaseUtcTime, timeZone); testDateTime outputs 15/08/2016 12:20:00 rather than 15/08/2016 11:20:00 why is this? Shouldn't it be 1 hour forward from UTC, not 2 ? EDIT---- Thanks Jon Skeet, If this helps anyone, i resorted to using:

Spring Mongodb Timestamp Timezone Misleading

依然范特西╮ 提交于 2019-12-10 22:56:19
问题 I am using Spring Data MongoDB. When I save some records MongoDb doesn't save correctly my timestamp. Here is my timestamp field in Spring. @DateTimeFormat(iso = DateTimeFormat.ISO.DATE_TIME) private Date timestamp = new Date(); My MongoDB record. { "_id": ObjectId("5697a672ce2a8e5347d86afd"), "batteryLevel": 100, "beaconClass": 3, "beaconId": "dsadsa", "timestamp": ISODate("2016-01-14T13:45:22.702Z") } When I log to console my timezone and date I see it is correct. Eastern European Time Asia

Loading a custom TimeZoneNameProvider in Java 8

∥☆過路亽.° 提交于 2019-12-10 22:22:00
问题 I'm trying to create custom naming for a timezone in Java 8. So I created a subclass of java.util.spi.TimeZoneNameProvider and implemented the required methods. Following the documentation I have also created a file called ./src/main/resources/META-INF/services/java.util.spi.TimeZoneNameProvider which contains a single line with the fully qualified name of my implementation. The final file in the jar file matches what I find in the documentation. The problem I have is that it does not get

How to SELECT the UTC offset from a DateTimeOffset object?

时光怂恿深爱的人放手 提交于 2019-12-10 22:09:08
问题 I am currently using: SELECT DATEPART(TZ, SYSDATETIMEOFFSET()) However, it returns the offset in minutes. I would like to preserve the format of '-05:00' instead of '-300' Thank you. 回答1: If you want to extract the exact string '-05:00' at the end of a datetimeoffset variable, you can use SQL Server string manipulation. I do not think it is possible to do this using the built-in SQL DateTime functions. You can use the CAST function, which I believe defaults to ISO 8601 format: declare

ORA-01882 after creating function based index with TIMESTAMP expression from dbms_metadata.get_ddl

无人久伴 提交于 2019-12-10 21:47:31
问题 We have a big existing script that drops and recreates tables in (a clone of) our customers database. Our customer might have changed table or index definitions slightly, so our script tries to use the output from dbms_metadata.get_ddl to recreate the tables, but we have problems with function based indices with timestamp expressions. Minimalistic example emulating a customer table: create table t(a timestamp, b timestamp); create index idx_ta on t (nvl(a, TO_DATE('2010-01-02 03:04:05','YYYY

Reading XML into Datatable gives incorrect DateTime when the time has Time Zone info

喜欢而已 提交于 2019-12-10 21:12:40
问题 So my client runs some code that writes their current time to an xml file which I then want to read back into a data table but I am getting incorrect time information. For example their current time is 09:31 their time zone is UTC+1:00 . my code is: var ds = new DataSet("MyDataSet"); var dt = ds.Tables.Add("MyDataTable"); dt.Columns.Add("MyDateTime", typeof(DateTime)); var startingDateTime = DateTime.Now; dt.Rows.Add(startingDateTime); String xmlDT = String.Empty; using (MemoryStream

TimeZoneInfo DST vs Windows settings

眉间皱痕 提交于 2019-12-10 21:07:49
问题 Does TimeZoneInfo.SupportsDaylightSavingTime reflect the disabled/enabled status of "Adjust for daylight saving time automatically" in Windows date & time settings? I'm trying to replicate those settings in a kiosk mode app where Windows is inaccessible for the user, and I've managed to get everything working including setting timezones with or without DST using tzutil, but while testing I noticed that some timezones DST settings (like Moscow) were not in sync with Windows. We know that

Change time zone for tomcat [duplicate]

孤者浪人 提交于 2019-12-10 21:00:48
问题 This question already has answers here : Change Timezone in Tomcat (4 answers) Closed 3 years ago . I have downloaded Tomcat 8 and copied the unzipped folder in my required path. I am using this tomcat as my server while running my web app. When I access system default time zone using java time package, actually the time zone of what I get. Is it system's clock setting? Or is it tomcat's settings. Where can I set time zone in tomcat. 回答1: Tomcat uses OS time settings. Best place is to set

Correct timezone list when using Moment or Internationalization API

假如想象 提交于 2019-12-10 20:59:04
问题 When I use MomentJS or Internationalization API, I get obsolete timezones like Asia/Katmandu or Asia/Calcutta in Chrome! These should instead be outputted as Asia/Kathmandu and Asia/Kolkata . How do I fix this? 回答1: Your question is a little bit misguided, as there's aren't generally such things in the tzdb as "obsoleted" time zones. In general , once the tzdb has introduced an identifier, it will continue to support it indefinitely - either as a Zone or as a Link . The only exception is