blob: 27c85d8c1a8524de0d0d81122daed921908f17d8 (
plain)
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
|
/*
* Copyright (c) 2014 Kevin Smith and Remko Tronçon
* All rights reserved.
*/
/*
* Copyright (c) 2014, Isode Limited, London, England.
* All rights reserved.
*/
package com.isode.stroke.base;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.TimeZone;
public class DateTime {
public static Date stringToDate(String date) {
SimpleDateFormat parser = new SimpleDateFormat(format);
parser.setTimeZone(TimeZone.getTimeZone("UTC"));
try {
return parser.parse(date);
} catch (ParseException e) {
return null;
}
}
public static String dateToString(Date date) {
SimpleDateFormat parser = new SimpleDateFormat(format);
parser.setTimeZone(TimeZone.getTimeZone("UTC"));
return parser.format(date);
}
static private String format = "yyyy-MM-dd'T'HH:mm:ss'Z'";
}
|