timezone

Django DateTimeField Stores datetime regardless of the tzinfo

喜欢而已 提交于 2019-12-18 09:49:14
问题 Why django DateTimeField restore tzinfo in datetime to <utc> ? Below is my test code. Is it normal or wrong.? If it is normal, what is the reason? models.py class Date(models.Model): datetime = models.DateTimeField() settings.py TIME_ZONE = 'Asia/Seoul' USE_TZ = True test.py from django.utils import timezone datetime = timezone.localtime(timezone.localtimezone.now()) #now datetime is datetime.datetime(2015, 10, 22, 20, 31, 56, 248000, tzinfo=<DstTzInfo 'Asia/Seoul' KST+9:00:00 STD>) models

Problem with timezone in Json response from Spring

淺唱寂寞╮ 提交于 2019-12-18 09:48:08
问题 I have a problem with displaying dates in JSON output. In code I use java.util.Date and its value is 2019-03-07 but in JSON I got 2019-03-06 23:00:00 . I think the problem is in timezone, but I don't use timezones in DB and in code too. I was trying to fix it with @JsonFormat(pattern = "yyyy-MM-dd hh:mm:ss", timezone="UTC") and @JsonFormat(pattern = "yyyy-MM-dd hh:mm:ss", timezone="Europe/Warsaw") The first didn't help, the second helped but I don't accept this solution. Part of my controller

Custom ZoneIds / Time Zones in Java

丶灬走出姿态 提交于 2019-12-18 09:39:12
问题 I'm attempting to model an iCalendar VTIMEZONE object using Java's ZoneId and ZoneOffsetTransitionRule . My VTIMEZONE object looks like BEGIN:VTIMEZONE TZID:Central European Standard Time BEGIN:STANDARD DTSTART:16010101T030000 TZOFFSETFROM:+0200 TZOFFSETTO:+0100 RRULE:FREQ=YEARLY;INTERVAL=1;BYDAY=-1SU;BYMONTH=10 END:STANDARD BEGIN:DAYLIGHT DTSTART:16010101T020000 TZOFFSETFROM:+0100 TZOFFSETTO:+0200 RRULE:FREQ=YEARLY;INTERVAL=1;BYMONTH=1;BYDAY=MO END:DAYLIGHT END:VTIMEZONE I need to create my

How can I change the timezone of the outputted date in Laravel 4?

心已入冬 提交于 2019-12-18 09:25:47
问题 I have a database with an entity table and a users table. The entity table has fields for created_at and updated_at . The users table has a timezone field with a default value of America/Toronto . In my view, I can output the date in the format I want with the following code: $entity->created_at->format('M j, Y \\a\\t g:i A') Now, how can I output the date using the timezone field in the users table? Something like ... $entity->created_at->format('M j, Y \\a\\t g:i A', Auth::user()->timezone)

How to get timezone from timezone offset in java?

倖福魔咒の 提交于 2019-12-18 09:04:11
问题 I know how to get the opposite. That is given a timezone I can get the timezone offset by the following code snippet: TimeZone tz = TimeZone.getDefault(); System.out.println(tz.getOffset(System.currentTimeMillis())); I want to know how to get the timezone name from timezone offset. Given, timezone offset = 21600000 (in milliseconds; +6.00 offset) I want to get result any of the following possible timezone names: (GMT+6:00) Antarctica/Vostok (GMT+6:00) Asia/Almaty (GMT+6:00) Asia/Bishkek (GMT

Setting session timezone with spring jdbc oracle

自闭症网瘾萝莉.ら 提交于 2019-12-18 08:14:26
问题 I have a spring/jdbc/oracle 10g application. The Oracle server database timezone is set to GMT + 2 JVM timezone is GMT + 2 (even though it doesn't matter in my case). I have a stored procedure that performs some date operations. The problem is that session timezone is different(GMT) than database timezone even though I do not set session timezone explicit in my code/configuration. As far as I know the session timezone is by default equal to database timezone. Any idea why is the session

How does one use TimeZoneInfo in a SQLCLR assembly in SQL Server 2012

半世苍凉 提交于 2019-12-18 06:53:32
问题 I want to implement time zone conversion within SQL Server 2012. However, TimeZoneInfo is marked with the MayLeakOnAbort attribute. This causes a runtime error when the SQL function I defined (which uses TimeZoneInfo) is invoked. The error is reported as follows System.Security.HostProtectionException: Attempted to perform an operation that was forbidden by the CLR host. The protected resources (only available with full trust) were: All The demanded resources were: MayLeakOnAbort

Java SimpleDateFormat parse Timezone like America/Los_Angeles

我与影子孤独终老i 提交于 2019-12-18 06:53:02
问题 I want to parse the following string in Java and convert it to a date: DTSTART;TZID=America/Los_Angeles:20140423T120000 I tried this: SimpleDateFormat sdf = new SimpleDateFormat("'DTSTART;TZID='Z':'yyyyMMdd'T'hhmmss"); Date start = sdf.parse("DTSTART;TZID=America/Los_Angeles:20140423T120000"); And this: SimpleDateFormat sdf = new SimpleDateFormat("'DTSTART;TZID='z':'yyyyMMdd'T'hhmmss"); Date start = sdf.parse("DTSTART;TZID=America/Los_Angeles:20140423T120000"); But it still doesn't work. I

Java SimpleDateFormat parse Timezone like America/Los_Angeles

牧云@^-^@ 提交于 2019-12-18 06:52:14
问题 I want to parse the following string in Java and convert it to a date: DTSTART;TZID=America/Los_Angeles:20140423T120000 I tried this: SimpleDateFormat sdf = new SimpleDateFormat("'DTSTART;TZID='Z':'yyyyMMdd'T'hhmmss"); Date start = sdf.parse("DTSTART;TZID=America/Los_Angeles:20140423T120000"); And this: SimpleDateFormat sdf = new SimpleDateFormat("'DTSTART;TZID='z':'yyyyMMdd'T'hhmmss"); Date start = sdf.parse("DTSTART;TZID=America/Los_Angeles:20140423T120000"); But it still doesn't work. I

How to detect change of system time in Linux?

ε祈祈猫儿з 提交于 2019-12-18 06:23:31
问题 Is there a way to get notified when there is update to the system time from a time-server or due to DST change? I am after an API/system call or equivalent. It is part of my effort to optimise generating a value for something similar to SQL NOW() to an hour granularity, without using SQL. 回答1: You can use timerfd_create(2) to create a timer, then mark it with the TFD_TIMER_CANCEL_ON_SET option when setting it. Set it for an implausible time in the future and then block on it (with poll/select