📄 test.java
字号:
package com.ntsky;
/**
* <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
*/
import java.util.*;
import java.text.*;
public class Test {
public static Date getNowDate() {
Date currentTime = new Date();
SimpleDateFormat formatter = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
String dateString = formatter.format(currentTime);
ParsePosition pos = new ParsePosition(8);
Date currentTime_2 = formatter.parse(dateString, pos);
return currentTime_2;
}
public static Date getNowDateShort() {
Date currentTime = new Date();
SimpleDateFormat formatter = new SimpleDateFormat("yyyy-MM-dd");
String dateString = formatter.format(currentTime);
ParsePosition pos = new ParsePosition(8);
Date currentTime_2 = formatter.parse(dateString, pos);
return currentTime_2;
}
public static long getS(String strDate){
SimpleDateFormat formatter = new SimpleDateFormat("yyyy-MM-dd");
ParsePosition pos = new ParsePosition(0);
Date strtodate = formatter.parse(strDate,pos);
return strtodate.getTime();
}
public static long getLongTime() {
return new Date().getTime();
}
public static void main(String[] args) {
Test t = new Test();
System.out.println("t.getNowDate() = "+t.getNowDateShort());
System.out.println("dd"+t.getS("2004-04-22"));
System.out.println("getLongTime"+t.getLongTime());
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -