Current date/time in Java under Citrix Xenapp 6.5

删除回忆录丶 提交于 2019-12-25 03:32:21

问题


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

回答1:


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:

  1. Select the Policies node
  2. Select the User tab
  3. Select the default "Unfiltered" policy
  4. Click Edit
  5. In the Edit Policy dialog select the Settings tab
  6. Scroll down to the "Time Zone Control" category and select it.
  7. Look for the "Use local time of client" setting and click Add.
  8. Click OK on the add dialog that pops up.
  9. Click OK on the Edit Policy dialog to close it.

The similar to step 12 in the support article I linked, run gpedit.msc:

  1. Select the node: Computer Configuration\Administrative Templates\Windows Components\Remote Desktop Services\Remote Desktop Session Host\Device and Resource Redirection
  2. Edit the "Allow time zone redirection" policy, to set it to Enabled.

Once the timezone redirection is setup you should be able to use the standard date/time APIs in any development language you choose.




回答2:


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



来源:https://stackoverflow.com/questions/29638378/current-date-time-in-java-under-citrix-xenapp-6-5

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!