📄 function.java
字号:
package com.wondersgroup.core;
import java.text.DateFormat;
import java.text.SimpleDateFormat;
import java.util.Locale;
public class Function {
/**
* method 将字符串类型的日期转换为一个timestamp(时间戳记java.sql.Timestamp)
*
* @param dateString
* 需要转换为timestamp的字符串
* @return dataTime timestamp
*/
public final static java.sql.Timestamp string2Time(String dateString)
throws java.text.ParseException {
DateFormat dateFormat;
dateFormat = new SimpleDateFormat("yyyy-MM-dd kk:mm:ss.SSS",
Locale.ENGLISH);// 设定格式
// dateFormat = new SimpleDateFormat("yyyy-MM-dd kk:mm:ss",
// Locale.ENGLISH);
dateFormat.setLenient(false);
java.util.Date timeDate = dateFormat.parse(dateString);// util类型
java.sql.Timestamp dateTime = new java.sql.Timestamp(timeDate.getTime());// Timestamp类型,timeDate.getTime()返回一个long型
return dateTime;
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -