Java – to in Oracle_ Display time zone description in char()
•
Java
I have an SQL query
select to_char(cast(sysdate as timestamp with LOCAL time zone),'YYYY-MM-DD,HH24:MI:SS TZR') from dual
This return output is
2015-08-06,04:09:10 +05:30
Anyone has any clue to get the output below
2015-08-06,04:09:10 IST
Thank you in advance
Solution
In general, you cannot display the time zone for the timestamp with local time zone value because it is always your current local time zone
05:30 is your current time zone. You can verify it in the following ways:
SELECT SESSIONTIMEZONE FROM dual;
You can't
ALTER SESSION SET TIME_ZONE = 'IST';
Because ist is also used for "Iceland standard time", "Ireland standard time", "Israel standard time", etc
However, you can use this:
SELECT TO_CHAR(CAST(LOCALTIMESTAMP AS TIMESTAMP WITH LOCAL TIME ZONE),HH24:MI:SS TZD') FROM dual;
Note that TZD stands for "daylight saving time information" If India has daylight saving time, your TZD may change
The content of this article comes from the network collection of netizens. It is used as a learning reference. The copyright belongs to the original author.
THE END
二维码