org.apache.brooklyn.util.time.Time.dropMilliseconds()方法的使用及代码示例

x33g5p2x  于2022-01-30 转载在 其他  
字(1.1k)|赞(0)|评价(0)|浏览(196)

本文整理了Java中org.apache.brooklyn.util.time.Time.dropMilliseconds()方法的一些代码示例,展示了Time.dropMilliseconds()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Time.dropMilliseconds()方法的具体详情如下:
包路径:org.apache.brooklyn.util.time.Time
类名称:Time
方法名:dropMilliseconds

Time.dropMilliseconds介绍

[英]removes milliseconds from the date object; needed if serializing to ISO-8601 format and want to serialize back and get the same data
[中]从日期对象中移除毫秒;如果序列化为ISO-8601格式并希望序列化回来并获得相同的数据,则需要

代码示例

代码示例来源:origin: org.apache.brooklyn.camp/camp-base

private void setCreated(Date created) {
  // precision beyond seconds breaks equals check
  this.created = Time.dropMilliseconds(created);
}
private void setTags(List<String> tags) {

代码示例来源:origin: org.apache.brooklyn/brooklyn-utils-common

@Test
public void testDateRoundingNull() {
  Assert.assertNull(Time.dropMilliseconds(null));
}

代码示例来源:origin: org.apache.brooklyn/brooklyn-utils-common

@Test
public void testDateRounding() {
  long x = System.currentTimeMillis();
  Date d1 = Time.dropMilliseconds(new Date(x));
  Date d2 = new Date(x - (x%1000));
  Date d3 = new Date( (x/1000)*1000 );
  Assert.assertEquals(d1.getTime() % 1000, 0);
  Assert.assertEquals(d1, d2);
  Assert.assertEquals(d1, d3);
}

相关文章