-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDateUtils.java
More file actions
29 lines (23 loc) · 761 Bytes
/
DateUtils.java
File metadata and controls
29 lines (23 loc) · 761 Bytes
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
package flightscheduleryjw5018.services;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Date;
public class DateUtils {
public static String formatDate(Date d) {
SimpleDateFormat df = new SimpleDateFormat("yyyy-MM-dd");
return df.format(d);
}
public static String formatTimestamp(Date d) {
SimpleDateFormat df = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
return df.format(d);
}
public static Date parseDate(String s) {
SimpleDateFormat df = new SimpleDateFormat("yyyy-MM-dd");
try {
Date d = df.parse(s);
return d;
} catch (ParseException e) {
return null;
}
}
}