📄 timerexpress.java
字号:
package com.ntsky.util;
import java.util.*;
import java.text.*;
import org.apache.log4j.Logger ;
/**
* <p>Title: Ntsky OpenSource BBS</p>
* <p>Description: 时间处理函数</p>
* <p>Copyright: Copyright (c) 2004</p>
* <p>Company: WWW.FM880.COM</p>
* @author 姚君林
* @version 1.0
*/
public class TimerExpress implements Timer{
private static String timeType = null;
private final static Logger logger = Logger.getRootLogger();
public TimerExpress(String timeType){
this.timeType = timeType;
}
/**
* 格式 : 输出timeType格式类型的时间
*/
public String getNowDate() {
String strTime = null;
try {
SimpleDateFormat simpledateformat = new SimpleDateFormat(timeType);
strTime = simpledateformat.format(new Date());
}
catch (Exception ex) {
logger.error("格式化" + timeType + "类型的时间错误 : error = "+ex.getMessage());
System.err.println("格式化" + timeType + "类型的时间错误 : error = "+ex.getMessage());
}
return strTime;
}
/**
* 将timeType转换后的浮点型的值
*/
public long getTimeToLong(String time) {
Date date = null;
try {
SimpleDateFormat formatter = new SimpleDateFormat(timeType);
ParsePosition pos = new ParsePosition(0);
date= formatter.parse(time,pos);
}
catch (Exception ex) {
logger.error("格式化" + timeType + "类型的时间错误 : error = " + ex.getMessage());
System.err.println("格式化" + timeType + "类型的时间错误 : error = " +
ex.getMessage());
}
return date.getTime();
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -