fix format and add test for fromISODateString
This commit is contained in:
parent
d8798e0bcf
commit
297617467e
2 changed files with 27 additions and 2 deletions
|
@ -27,8 +27,8 @@ public class DateUtil {
|
|||
/**
|
||||
* 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_MSEC = "yyyy-MM-dd'T'HH:mm:ss.SSS'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.SSSZ";
|
||||
|
||||
/**
|
||||
* Takes in an ISO date string of the following format:
|
||||
|
|
25
app/src/test/java/info/nightscout/utils/DateUtilTest.java
Normal file
25
app/src/test/java/info/nightscout/utils/DateUtilTest.java
Normal 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());
|
||||
}
|
||||
|
||||
|
||||
}
|
Loading…
Reference in a new issue