forked from plusone/plusone-commons
统一工具类命名规则。
This commit is contained in:
@@ -11,40 +11,40 @@ import org.junit.jupiter.api.Test;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
class DateTimeUtilTests {
|
||||
class DateTimeToolsTests {
|
||||
|
||||
private static final Logger log = LoggerFactory.getLogger(DateTimeUtilTests.class);
|
||||
private static final Logger log = LoggerFactory.getLogger(DateTimeToolsTests.class);
|
||||
|
||||
@Test
|
||||
void testLocalNowStr() {
|
||||
log.info(DateTimeUtil.nowStr("yyyy/MM/dd HH:mm:ss.SSS"));
|
||||
log.info(DateTimeTools.nowStr("yyyy/MM/dd HH:mm:ss.SSS"));
|
||||
}
|
||||
|
||||
@Test
|
||||
void testToJoda() {
|
||||
LocalDateTime now = LocalDateTime.now();
|
||||
log.info("now: {}", now);
|
||||
org.joda.time.LocalDateTime now2 = DateTimeUtil.toJodaLocalDateTime(now);
|
||||
org.joda.time.LocalDateTime now2 = DateTimeTools.toJodaLocalDateTime(now);
|
||||
log.info("now2: {}", now2);
|
||||
}
|
||||
|
||||
@Test
|
||||
void testToInstant() {
|
||||
Instant now = DateTimeUtil.toInstant(System.currentTimeMillis());
|
||||
String str = DateTimeUtil.toString("yy-M-d HH:mm:ss.SSS", now);
|
||||
Instant now = DateTimeTools.toInstant(System.currentTimeMillis());
|
||||
String str = DateTimeTools.toString("yy-M-d HH:mm:ss.SSS", now);
|
||||
log.info(str);
|
||||
}
|
||||
|
||||
@Test
|
||||
void testToJodaDateTime() {
|
||||
DateTime jodaDateTime = DateTimeUtil.toJodaDateTime(Instant.now(), ZoneId.of("+08:00"));
|
||||
DateTime jodaDateTime = DateTimeTools.toJodaDateTime(Instant.now(), ZoneId.of("+08:00"));
|
||||
log.info("jodaDateTime: {}", jodaDateTime);
|
||||
}
|
||||
|
||||
@Test
|
||||
void test() {
|
||||
Instant now = Instant.now();
|
||||
DateTime jodaDateTime = DateTimeUtil.toJodaDateTime(now, ZoneId.of("America/New_York"));
|
||||
DateTime jodaDateTime = DateTimeTools.toJodaDateTime(now, ZoneId.of("America/New_York"));
|
||||
DateTimeFormatter formatter = DateTimeFormat.forPattern("yyyy-MM-dd HH:mm:ss.SSS");
|
||||
log.info(formatter.print(jodaDateTime));
|
||||
log.info(jodaDateTime.getZone().toString());
|
||||
@@ -52,7 +52,7 @@ class DateTimeUtilTests {
|
||||
log.info("==========================================");
|
||||
org.joda.time.Instant instant = new org.joda.time.Instant(System.currentTimeMillis() - 500000);
|
||||
log.info(instant.toString());
|
||||
log.info(DateTimeUtil.toJavaInstant(instant).toString());
|
||||
log.info(DateTimeUtil.toZonedDateTime(instant, DateTimeZone.forID("America/New_York")).toString());
|
||||
log.info(DateTimeTools.toJavaInstant(instant).toString());
|
||||
log.info(DateTimeTools.toZonedDateTime(instant, DateTimeZone.forID("America/New_York")).toString());
|
||||
}
|
||||
}
|
@@ -1,39 +0,0 @@
|
||||
package xyz.zhouxy.plusone.commons.util;
|
||||
|
||||
import static org.junit.jupiter.api.Assertions.assertFalse;
|
||||
import static org.junit.jupiter.api.Assertions.assertTrue;
|
||||
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
class NumberUtilTest {
|
||||
private static final Logger log = LoggerFactory.getLogger(NumberUtilTest.class);
|
||||
|
||||
@Test
|
||||
void testSum() {
|
||||
long result = 0;
|
||||
for (int i = 0; i < Integer.MAX_VALUE; i++) {
|
||||
result += Short.MAX_VALUE;
|
||||
}
|
||||
log.info("Integer.MAX_VALUE: {}", Integer.MAX_VALUE);
|
||||
log.info("result: {}", result);
|
||||
assertFalse(Integer.MAX_VALUE > result);
|
||||
|
||||
result = 0;
|
||||
for (int i = 0; i < Integer.MAX_VALUE; i++) {
|
||||
result += Short.MAX_VALUE;
|
||||
}
|
||||
log.info("Long.MAX_VALUE: {}", Long.MAX_VALUE);
|
||||
log.info("result: {}", result);
|
||||
assertTrue(Long.MAX_VALUE > result);
|
||||
|
||||
result = 0;
|
||||
for (int i = 0; i < Integer.MAX_VALUE; i++) {
|
||||
result += Integer.MAX_VALUE;
|
||||
}
|
||||
log.info("Long.MAX_VALUE: {}", Long.MAX_VALUE);
|
||||
log.info("result: {}", result);
|
||||
assertTrue(Long.MAX_VALUE > result);
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user