tbDate:fix bug now
This commit is contained in:
parent
c42599c0d9
commit
e7dc68f18f
@ -218,9 +218,12 @@ public class TbDate implements Serializable, Cloneable {
|
|||||||
return opt;
|
return opt;
|
||||||
}
|
}
|
||||||
|
|
||||||
public long now() {
|
public static long now() {
|
||||||
return Instant.now().toEpochMilli();
|
return Instant.now().toEpochMilli();
|
||||||
}
|
}
|
||||||
|
public static String nowToString() {
|
||||||
|
return Instant.now().toString();
|
||||||
|
}
|
||||||
|
|
||||||
public long parseSecond() {
|
public long parseSecond() {
|
||||||
return instant.getEpochSecond();
|
return instant.getEpochSecond();
|
||||||
|
|||||||
@ -29,7 +29,6 @@ import org.thingsboard.common.util.JacksonUtil;
|
|||||||
|
|
||||||
import java.time.DateTimeException;
|
import java.time.DateTimeException;
|
||||||
import java.time.ZoneId;
|
import java.time.ZoneId;
|
||||||
import java.time.format.DateTimeFormatter;
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Locale;
|
import java.util.Locale;
|
||||||
@ -40,6 +39,7 @@ import java.util.concurrent.TimeUnit;
|
|||||||
import java.util.concurrent.TimeoutException;
|
import java.util.concurrent.TimeoutException;
|
||||||
|
|
||||||
import static org.assertj.core.api.Assertions.assertThat;
|
import static org.assertj.core.api.Assertions.assertThat;
|
||||||
|
import static org.junit.Assert.assertNotNull;
|
||||||
import static org.junit.Assert.assertThrows;
|
import static org.junit.Assert.assertThrows;
|
||||||
import static org.junit.Assert.assertTrue;
|
import static org.junit.Assert.assertTrue;
|
||||||
|
|
||||||
@ -484,6 +484,12 @@ class TbDateTest {
|
|||||||
Assert.assertEquals(expected, d.toLocaleString());
|
Assert.assertEquals(expected, d.toLocaleString());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void TestNow() {
|
||||||
|
assertTrue(TbDate.now() > 0);
|
||||||
|
assertNotNull(TbDate.nowToString());
|
||||||
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void TestToUTC() {
|
public void TestToUTC() {
|
||||||
Assert.assertEquals(-2209075200000L, TbDate.UTC(0));
|
Assert.assertEquals(-2209075200000L, TbDate.UTC(0));
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user