📄 timestring.java
字号:
package scz;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Date;
import org.yeeku.exception.ExamException;
public class TimeString implements ITimeString{
SimpleDateFormat sdf=new SimpleDateFormat("yyyy-MM-dd hh:mm:ss");
SimpleDateFormat sdf1=new SimpleDateFormat("yyyy年MM月dd日 hh:mm:ss");
SimpleDateFormat sdf2=new SimpleDateFormat("yyyy-MM-dd");
SimpleDateFormat sdf3=new SimpleDateFormat("yyyy年MM月dd日");
public Date getNowDate()throws ExamException {
// TODO Auto-generated method stub
return new Date();
}
public String dateToString(Date date)throws ExamException {
// TODO Auto-generated method stub
try {
return sdf1.format(date);
} catch (Exception e) {
// TODO Auto-generated catch block
e.printStackTrace();
throw new ExamException("日期转成字符串出错");
}
}
public Date stringToDate(String str)throws ExamException {
// TODO Auto-generated method stub
try {
return sdf.parse(str);
} catch (ParseException e) {
// TODO Auto-generated catch block
e.printStackTrace();
throw new ExamException("字符串转成日期出错");
}
}
public String dateToStringTo(Date date)throws ExamException {
// TODO Auto-generated method stub
try {
return sdf1.format(date);
} catch (Exception e) {
// TODO Auto-generated catch block
e.printStackTrace();
throw new ExamException("日期转成字符串出错");
}
}
public Date stringToDateTo(String str)throws ExamException {
// TODO Auto-generated method stub
try {
return sdf.parse(str);
} catch (ParseException e) {
// TODO Auto-generated catch block
e.printStackTrace();
throw new ExamException("字符串转成日期出错");
}
}
public static void main(String[] args) {
// TODO Auto-generated method stub
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -