使用日历类injava同步服务器时间 [英] synchronizing servers time using calendar class injava

查看:147
本文介绍了使用日历类injava同步服务器时间的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经构建了两个服务器在Web服务使用java.My问题是,我无法弄清楚如何同步服务器时间使用日历类在java.I将很高兴,如果你帮助我,至少它



感谢

解决方案

div>

我不认为你应该使用Java来同步它们之间的系统时间。有一个成熟且广泛传播的协议可用于此问题:网络时间协议



否则您必须处理




  • 网络延迟

  • 内部CMOS时钟漂移

  • 获得正确的参考日期

  • 系统权限:通常需要root才能更改时间...,


  • 当然,所有这些问题都是在NTP中解决的。


    I have constructed two servers in web service using java.My problem is that i couldn't figure out how can i synchronize servers time using calendar class in java.I would be glad if you help me with that, at least it would be nice to give me an example how can i do that.

    Thanks

    解决方案

    I don't think that you should use Java to sync the system times between them. There is a matured and widely spread protocol available for this issue: The Network Time Protocol

    Otherwise you have to deal with

    • network latency
    • time drifts of internal CMOS clock
    • getting the correct reference date
    • system rights: normally root is required to change the time ... and you don't want your web service running as root?

    Of course, all of these issues is solved in NTP.

    这篇关于使用日历类injava同步服务器时间的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆