-
Notifications
You must be signed in to change notification settings - Fork 10
Expand file tree
/
Copy pathDateUtil.java
More file actions
36 lines (31 loc) · 1.04 KB
/
DateUtil.java
File metadata and controls
36 lines (31 loc) · 1.04 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
package com.realmo.utils;
import java.text.ParseException;
import java.text.ParsePosition;
import java.text.SimpleDateFormat;
import java.util.Date;
/**
* @ClassName: DateUtil
* @Author: Administrator
* @Date: 2016/5/26 17:03
*/
public class DateUtil {
public static Date stringToDate(String dateString) {
ParsePosition position = new ParsePosition(0);
SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy/MM/dd HH:mm:ss");
Date dateValue = simpleDateFormat.parse(dateString, position);
return dateValue;
}
public static String stringToString(String dateString) {
// ParsePosition position = new ParsePosition(0);
String str = null;
SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy/MM/dd HH:mm:ss");
Date dateValue = null;
try {
dateValue = simpleDateFormat.parse(dateString);
str = simpleDateFormat.format(dateValue);
} catch (ParseException e) {
e.printStackTrace();
}
return str;
}
}