This commit is contained in:
Looly
2021-08-30 12:52:10 +08:00
parent 424e6e817e
commit fca32ecefd
4 changed files with 60 additions and 3 deletions

View File

@@ -86,6 +86,12 @@ public class LocalDateTimeUtilTest {
Assert.assertEquals("2020-01-23", localDate.toString());
}
@Test
public void parseSingleMonthAndDayTest() {
LocalDate localDate = LocalDateTimeUtil.parseDate("2020-1-1", "yyyy-M-d");
Assert.assertEquals("2020-01-01", localDate.toString());
}
@Test
public void formatTest() {
final LocalDateTime localDateTime = LocalDateTimeUtil.parse("2020-01-23T12:23:56");

View File

@@ -0,0 +1,23 @@
package cn.hutool.core.math;
import org.junit.Assert;
import org.junit.Test;
public class MoneyTest {
@Test
public void yuanToCentTest() {
final Money money = new Money("1234.56");
Assert.assertEquals(123456, money.getCent());
Assert.assertEquals(123456, MathUtil.yuanToCent(1234.56));
}
@Test
public void centToYuanTest() {
final Money money = new Money(1234, 56);
Assert.assertEquals(1234.56D, money.getAmount().doubleValue(), 2);
Assert.assertEquals(1234.56D, MathUtil.centToYuan(123456), 2);
}
}