fix format and add test for fromISODateString

This commit is contained in:
Milos Kozak 2017-11-20 13:34:13 +01:00
parent d8798e0bcf
commit 297617467e
2 changed files with 27 additions and 2 deletions

View file

@ -27,8 +27,8 @@ public class DateUtil {
/** /**
* The date format in iso. * The date format in iso.
*/ */
private static String FORMAT_DATE_ISO = "yyyy-MM-dd'T'HH:mm:ss'Z'"; private static String FORMAT_DATE_ISO = "yyyy-MM-dd'T'HH:mm:ssZ";
private static String FORMAT_DATE_ISO_MSEC = "yyyy-MM-dd'T'HH:mm:ss.SSS'Z'"; private static String FORMAT_DATE_ISO_MSEC = "yyyy-MM-dd'T'HH:mm:ss.SSSZ";
/** /**
* Takes in an ISO date string of the following format: * Takes in an ISO date string of the following format:

View file

@ -0,0 +1,25 @@
package info.nightscout.utils;
import org.junit.Test;
import static org.junit.Assert.*;
/**
* Created by mike on 20.11.2017.
*/
public class DateUtilTest {
public DateUtilTest() {
super();
}
@Test
public void fromISODateStringTest() throws Exception {
assertEquals( 1511124634417L, DateUtil.fromISODateString("2017-11-19T22:50:34.417+0200").getTime());
assertEquals( 1511124634000L, DateUtil.fromISODateString("2017-11-19T22:50:34+0200").getTime());
}
}