We maintain a legacy Java application which has just recently migrated to the XenApp 6.5 platform.
But when we display the current time it is displaying the server time and not the user's time on the Powered Shared Desktop.
For example, the user is in timezone offset 9.5, but when outputting the timezone it is displayed as 10.
We have tried:
TimeZone.getDefault().getID());
System.getProperty("user.timezone"));
And we are getting the time by:
private final static DateFormat dateFormat = new SimpleDateFormat("dd/MM/yyyy HH:mm:ss");
private Calendar intCal;
intCal = Calendar.getInstance();
intCal.setTimeInMillis(System.currentTimeMillis());
String df = dateFormat.format(intCal.getTime());
Is there an offical way to get the user's time?
Also using a VBS it outputs the same:
strComputer = "."
Set objWMIService = GetObject("winmgmts:" _
& "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")
Set colTimeZone = objWMIService.ExecQuery("Select * from Win32_TimeZone")
For Each objTimeZone in colTimeZone
Wscript.Echo "Offset: "& objTimeZone.Bias / 60
Next
You need to make sure timezone redirection is enabled so that the server session uses the timezone of the client device. In XenApp 6.5 you have to turn this on in two places, in both the Citrix specific XenApp policies and the Windows RDS policies.
The following article shows how you would do it in a production environment by setting up GPOs to configure both policy settings:
http://support.citrix.com/article/CTX126099
However if you want to just quickly test this on a single server you can just edit everything locally. I.e. first open Citrix AppCenter then:
The similar to step 12 in the support article I linked, run gpedit.msc:
Once the timezone redirection is setup you should be able to use the standard date/time APIs in any development language you choose.
I have found that this is a bug within the JRE itself and it was raised in 2011, it has recently been fixed in the early release of Java 9:
http://bugs.java.com/bugdatabase/view_bug.do?bug_id=7044727