📄 windowstime.java
字号:
package edu.swjtu.sist.java.calendar;
/**
* 该类通过本地方法private static native boolean setTime(int year, int month, int day, int hour, int min, int sec);
* 来将应用程序的修改后的时间应用为真实的系统时间。
*
* 需要使用JNI分别实现windows下的*.DLL,和linux下的*.SO
*
* @author 518lee@gmail.com
* @version 1.0
*/
public class WindowsTime
{
public WindowsTime()
{
}
public static boolean hasModified=false;
private static native boolean setTime(int year, int month, int day, int hour, int min, int sec);
public static void setLocalTime(int year, int month, int day, int hour, int min, int sec)
throws TimeOutException
{
if(year < 1980)
throw new TimeOutException("year");
if((month < 0) | (month > 12))
throw new TimeOutException("month");
if((day < 1) | (day > 31))
throw new TimeOutException("day");
if((hour < 0) | (hour > 23))
throw new TimeOutException("hour");
if((min < 0) | (min > 59))
throw new TimeOutException("minutes");
if((sec < 0) | (sec > 59))
throw new TimeOutException("seconds");
if(!setTime(year, month, day, hour, min, sec))
throw new TimeOutException("All");
else
return;
}
static
{
System.loadLibrary("SetSysTime");
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -