Search code examples
javadatetimetimezonecitrixxenapp

Current date/time in Java under Citrix Xenapp 6.5


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

Solution

  • 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