Tag: ntp

使用TimeTCPClient从公共时间服务器获取时间

我尝试使用以下代码从公共时间服务器获取时间。 package aaa; import java.util.Arrays; import java.util.List; import org.apache.commons.net.TimeTCPClient; public final class Main { public static java.util.Date getNTPDate() { List hosts = Arrays.asList(“0.pool.ntp.org”); for (String host : hosts) { TimeTCPClient client = new TimeTCPClient(); // We want to timeout if a response takes longer than 5 seconds client.setDefaultTimeout(5000); try { client.connect(host); java.util.Date ntpDate = client.getDate(); […]

如何通过系统时钟篡改来防止过期许可证的使用?

我目前正在使用java工作的许可证管理器,我将指定我的应用程序的开始和结束日期,以便我可以强制许可用户在一定时间后重新许可该程序。 但我面临的问题是,任何人都可以回滚他们的系统日期和时间,以保持许可证的有效性。 Java中是否有任何方法可以检测系统日期和时间是否已更改。 我已经尝试过网络时间协议来从时间服务器获取当前日期和时间。

Java调度程序完全独立于系统时间的变化

使用Java Timer,然后切换到ScheduledExecutorService,但我的问题没有修复。 在系统时间更改之前安排的任务(通过ntpd)不会在指定的延迟时执行。 没有任何日志记录相同:(。 在64位linux上使用我的目标中的jre 1.6.0_26 64位。 更新: ScheduledExecutorService在Windows上运行正常。 问题仅出在运行64位JVM的基于64位Linux的系统上。 它在运行32位JVM的64位linux上运行良好……很奇怪。 在任何博客上都没有找到任何相同的参考。 IBM的JAVA SDK也存在同样的问题(ibm-java-sdk-7.0-0.0-x86_64-archive.bin)。 我已经提交了针对JDK 7139684的缺陷,它被接受但已被关闭并标记为6900441的副本 。 请投票给它,如果你觉得它的价值得到修复…我不知道为什么它已经修复了几年以上 以下是我用来测试此问题的示例代码: package test; import java.io.IOException; import java.util.Date; import java.util.concurrent.Executors; import java.util.concurrent.ScheduledExecutorService; import java.util.concurrent.TimeUnit; /** * @author yogesh * */ public class TimerCheck implements Runnable { ScheduledExecutorService worker; public TimerCheck(ScheduledExecutorService worker) { super(); this.worker = worker; this.worker.schedule(this, 1, […]