字符串 转换成 Timestamp
来源:互联网 发布:简单算法题 编辑:程序博客网 时间:2024/06/02 18:27
/**
* @param String time
* @return Timestamp
* @throws ParseException
*/
private static Timestamp StringToTimestamp(String time) throws ParseException {
// TODO Auto-generated method stub
// 方法一 :
// String[] timeStr = time.split("_");
// int[] t = new int[timeStr.length];
// for (int i = 0; i < timeStr.length; i++) {
// t[i] = Integer.parseInt(timeStr[i]);
// }
// Timestamp timestamp = new Timestamp(t[0]-1900,t[1] - 1,t[2],t[3],t[4],t[5],0);
// 方法二 :
// SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy_MM_dd_HH_mm_ss");
// Date date = dateFormat.parse(time);
// 方法三 :
SimpleDateFormat dateFormat = new SimpleDateFormat("yyyyMMddHHmmss");
Date date = dateFormat.parse(time.replaceAll("_", ""));
Timestamp timestamp = new Timestamp(date.getTime());
return timestamp;
}
* @param String time
* @return Timestamp
* @throws ParseException
*/
private static Timestamp StringToTimestamp(String time) throws ParseException {
// TODO Auto-generated method stub
// 方法一 :
// String[] timeStr = time.split("_");
// int[] t = new int[timeStr.length];
// for (int i = 0; i < timeStr.length; i++) {
// t[i] = Integer.parseInt(timeStr[i]);
// }
// Timestamp timestamp = new Timestamp(t[0]-1900,t[1] - 1,t[2],t[3],t[4],t[5],0);
// 方法二 :
// SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy_MM_dd_HH_mm_ss");
// Date date = dateFormat.parse(time);
// 方法三 :
SimpleDateFormat dateFormat = new SimpleDateFormat("yyyyMMddHHmmss");
Date date = dateFormat.parse(time.replaceAll("_", ""));
Timestamp timestamp = new Timestamp(date.getTime());
return timestamp;
}
- 字符串 转换成 Timestamp
- oracle timestamp与字符串转换
- oracle timestamp与字符串转换
- Timestamp 类型的时间转换成字符串
- oracle,mysql中字符串,date,timestamp转换
- 将Timestamp转换成Date
- timestamp转换成Date格式
- Timestamp的作用及与字符串的相互转换
- Oracle 字符串转换TIMESTAMP类型或Date类型
- 字符串 与 java.sql.Timestamp转换博客分类: javaJavaSQL
- Java项目实战 字符串 与 java.sql.Timestamp转换类
- Oracle 字符串转换TIMESTAMP类型或Date类型
- oracle中的sql语句中timestamp与字符串转换
- Oracle timestamp类型转换成date类型
- 将java日期转换成timestamp
- 不同timestamp的转换
- VARCHAR2转换TIMESTAMP
- String转换为Timestamp
- PHP中$_SERVER的详细用法
- 如何保持愉悦的身心状态,做个时尚的健康人
- SQL2005中大数据量检索的分页(转)
- KMP算法详解
- javascrip 树型菜单
- 字符串 转换成 Timestamp
- 美国GIS的19个研究方向
- 开通博客
- Flex+Spring配置
- php利用cookie防止在规定时间内刷新
- 一步步用SDK构建记事本程序(二)
- Eclipse3.4 插件配置的几种方式
- 表单验证
- 系统月报格式