forked from fanruan/finekit
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
19 lines
610 B
19 lines
610 B
6 years ago
|
package com.fanruan.api.util;
|
||
|
|
||
|
import java.util.Date;
|
||
|
import java.text.DateFormat;
|
||
|
import java.text.SimpleDateFormat;
|
||
|
import org.junit.Assert;
|
||
|
import org.junit.Test;
|
||
|
|
||
|
public class DateKitTest {
|
||
|
@Test
|
||
|
public void string2Date() throws Exception{
|
||
|
DateFormat dateFormat2 = new SimpleDateFormat("yyyy-MM-dd");
|
||
|
Date myDate = dateFormat2.parse("2019-02-20");
|
||
|
Assert.assertEquals(DateKit.string2Date("2019-02-20", false), myDate);
|
||
|
Assert.assertEquals(DateKit.string2Date("abcd", false), new Date());
|
||
|
Assert.assertEquals(DateKit.string2Date("abcd", true), null);
|
||
|
}
|
||
|
}
|