如何获取计算机而不是服务器Java vaadin的时间 [英] How to get the time of Computer and not server Java vaadin
本文介绍了如何获取计算机而不是服务器Java vaadin的时间的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
嘿,如何获取计算机的时间而不是使用vaadin的服务器,因为getDate返回我服务器的时间,但是我要客户端计算机的时间??
Hey how to get the time of the computer and not the server using vaadin because getDate return to me the time of the server but i want the client computer time ??
推荐答案
Vaadin有一个名为WebBrowser的类,该类提供有关客户端(浏览器)的有用信息:
Vaadin has a class called WebBrowser that provides useful information about the client (browser):
例如,您可以访问当前的WebBrowser实例,如下所示:
You can access the current WebBrowser instance for example as follows:
public class MyApplication extends Application {
@Override
public void init() {
setMainWindow(new Window());
ApplicationContext context = this.getContext();
if (context instanceof WebApplicationContext) {
WebBrowser webBrowser = ((WebApplicationContext) this.getContext()).getBrowser();
Date now = webBrowser.getCurrentDate(); // Returns the current date and time on the browser
}
}
}
有关WebBrowser类的更多信息,请参见其 JavaDocs .
For more information about the WebBrowser class, see its JavaDocs.
这篇关于如何获取计算机而不是服务器Java vaadin的时间的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文