org.joda.time.LocalTime.now()方法的使用及代码示例

x33g5p2x  于2022-01-23 转载在 其他  
字(8.3k)|赞(0)|评价(0)|浏览(247)

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

LocalTime.now介绍

[英]Obtains a LocalTime set to the current system millisecond time using ISOChronology in the default time zone. The resulting object does not use the zone.
[中]使用默认时区中的ISOChronology获取设置为当前系统毫秒时间的LocalTime。生成的对象不使用分区。

代码示例

代码示例来源:origin: apache/avro

@Test(expected = MissingSchemaException.class)
 public void testSpecificByteArrayIncompatibleWithoutLogicalTypes() throws IOException {
  TestRecordWithLogicalTypes withLogicalTypes = new TestRecordWithLogicalTypes(
    true,
    34,
    35L,
    3.14F,
    3019.34,
    null,
    LocalDate.now(),
    LocalTime.now(),
    DateTime.now().withZone(DateTimeZone.UTC),
    new BigDecimal("123.45")
  );

  ByteBuffer b = withLogicalTypes.toByteBuffer();
  TestRecordWithoutLogicalTypes.fromByteBuffer(b);
 }
}

代码示例来源:origin: apache/avro

@Test
public void testSpecificToFromByteBufferWithLogicalTypes() throws IOException {
 TestRecordWithLogicalTypes record = new TestRecordWithLogicalTypes(
   true,
   34,
   35L,
   3.14F,
   3019.34,
   null,
   LocalDate.now(),
   LocalTime.now(),
   DateTime.now().withZone(DateTimeZone.UTC),
   new BigDecimal("123.45")
 );
 ByteBuffer b = record.toByteBuffer();
 TestRecordWithLogicalTypes copy = TestRecordWithLogicalTypes.fromByteBuffer(b);
 assertEquals(record, copy);
}

代码示例来源:origin: apache/avro

@Test
public void testRecordWithLogicalTypes() throws IOException {
 TestRecordWithLogicalTypes record = new TestRecordWithLogicalTypes(
   true,
   34,
   35L,
   3.14F,
   3019.34,
   null,
   LocalDate.now(),
   LocalTime.now(),
   DateTime.now().withZone(DateTimeZone.UTC),
   new BigDecimal(123.45f).setScale(2, RoundingMode.HALF_DOWN)
 );
 File data = write(TestRecordWithLogicalTypes.getClassSchema(), record);
 List<TestRecordWithLogicalTypes> actual = read(
   TestRecordWithLogicalTypes.getClassSchema(), data);
 Assert.assertEquals("Should match written record", record, actual.get(0));
}
@Test

代码示例来源:origin: apache/avro

null,
LocalDate.now(),
LocalTime.now(),

代码示例来源:origin: apache/avro

@Test
public void testRecordWithoutLogicalTypes() throws IOException {
 // the significance of the record without logical types is that it has the
 // same schema (besides record name) as the one with logical types,
 // including the type annotations. this verifies that the type annotations
 // are only applied if the record was compiled to use those types. this
 // ensures compatibility with already-compiled code.
 TestRecordWithoutLogicalTypes record = new TestRecordWithoutLogicalTypes(
   true,
   34,
   35L,
   3.14F,
   3019.34,
   null,
   new DateConversion().toInt(LocalDate.now(), null, null),
   new TimeConversion().toInt(LocalTime.now(), null, null),
   new TimestampConversion().toLong(
     DateTime.now().withZone(DateTimeZone.UTC), null, null),
   new Conversions.DecimalConversion().toBytes(
     new BigDecimal(123.45f).setScale(2, RoundingMode.HALF_DOWN), null,
     LogicalTypes.decimal(9, 2))
 );
 File data = write(TestRecordWithoutLogicalTypes.getClassSchema(), record);
 List<TestRecordWithoutLogicalTypes> actual = read(
   TestRecordWithoutLogicalTypes.getClassSchema(), data);
 Assert.assertEquals("Should match written record", record, actual.get(0));
}

代码示例来源:origin: apache/avro

@Test(expected = MissingSchemaException.class)
public void testSpecificByteArrayIncompatibleWithLogicalTypes() throws IOException {
 TestRecordWithoutLogicalTypes withoutLogicalTypes = new TestRecordWithoutLogicalTypes(
   true,
   34,
   35L,
   3.14F,
   3019.34,
   null,
   new TimeConversions.DateConversion().toInt(LocalDate.now(), null, null),
   new TimeConversions.TimeConversion().toInt(LocalTime.now(), null, null),
   new TimeConversions.TimestampConversion().toLong(
     DateTime.now().withZone(DateTimeZone.UTC), null, null),
   new Conversions.DecimalConversion().toBytes(
     new BigDecimal("123.45"), null, LogicalTypes.decimal(9, 2))
 );
 ByteBuffer b = withoutLogicalTypes.toByteBuffer();
 TestRecordWithLogicalTypes.fromByteBuffer(b);
}

代码示例来源:origin: dlew/joda-time-android

assertEquals("3 days ago", DateUtils.getRelativeTimeSpanString(ctx, LocalDate.now().minusDays(3)));
assertEquals("in 1 hour", DateUtils.getRelativeTimeSpanString(ctx, LocalTime.now().plusHours(1)));
assertEquals("in 3 hours", DateUtils.getRelativeTimeSpanString(ctx, LocalTime.now().plusHours(3)));
assertEquals("1 hour ago", DateUtils.getRelativeTimeSpanString(ctx, LocalTime.now().minusHours(1)));
assertEquals("3 hours ago", DateUtils.getRelativeTimeSpanString(ctx, LocalTime.now().minusHours(3)));
assertEquals("in 1 min", DateUtils.getRelativeTimeSpanString(ctx, LocalTime.now().plusMinutes(1),
  DateUtils.FORMAT_ABBREV_RELATIVE));
assertEquals("in 30 mins", DateUtils.getRelativeTimeSpanString(ctx, LocalTime.now().plusMinutes(30),
  DateUtils.FORMAT_ABBREV_RELATIVE));
assertEquals("1 min ago", DateUtils.getRelativeTimeSpanString(ctx, LocalTime.now().minusMinutes(1),
  DateUtils.FORMAT_ABBREV_RELATIVE));
assertEquals("30 mins ago", DateUtils.getRelativeTimeSpanString(ctx, LocalTime.now().minusMinutes(30),
  DateUtils.FORMAT_ABBREV_RELATIVE));

代码示例来源:origin: apache/avro

@Test
public void testSpecificToFromByteBufferWithoutLogicalTypes() throws IOException {
 TestRecordWithoutLogicalTypes record = new TestRecordWithoutLogicalTypes(
   true,
   34,
   35L,
   3.14F,
   3019.34,
   null,
   new TimeConversions.DateConversion().toInt(LocalDate.now(), null, null),
   new TimeConversions.TimeConversion().toInt(LocalTime.now(), null, null),
   new TimeConversions.TimestampConversion().toLong(
     DateTime.now().withZone(DateTimeZone.UTC), null, null),
   new Conversions.DecimalConversion().toBytes(
     new BigDecimal("123.45"), null, LogicalTypes.decimal(9, 2))
 );
 ByteBuffer b = record.toByteBuffer();
 TestRecordWithoutLogicalTypes copy = TestRecordWithoutLogicalTypes.fromByteBuffer(b);
 assertEquals(record, copy);
}

代码示例来源:origin: apache/avro

@Test
public void testRecordWriteLogicalTypesReadPrimitives() throws IOException {
 LocalDate date = LocalDate.now();
 LocalTime time = LocalTime.now();
 DateTime timestamp = DateTime.now().withZone(DateTimeZone.UTC);
 BigDecimal decimal = new BigDecimal(123.45f).setScale(2, RoundingMode.HALF_DOWN);

代码示例来源:origin: apache/avro

@Test
public void testRecordWritePrimitivesReadLogicalTypes() throws IOException {
 LocalDate date = LocalDate.now();
 LocalTime time = LocalTime.now();
 DateTime timestamp = DateTime.now().withZone(DateTimeZone.UTC);
 BigDecimal decimal = new BigDecimal(123.45f).setScale(2, RoundingMode.HALF_DOWN);

代码示例来源:origin: dlew/joda-time-android

LocalTime lt = LocalTime.now();
assertEquals("in 30 seconds, 12:35", DateUtils.getRelativeDateTimeString(ctx, lt.plusSeconds(30), null, 0));
assertEquals("30 seconds ago, 12:34", DateUtils.getRelativeDateTimeString(ctx, lt.minusSeconds(30), null, 0));

代码示例来源:origin: org.actframework/act

@Override
  public LocalTime now() {
    return LocalTime.now();
  }
}

代码示例来源:origin: actframework/actframework

@Override
  public LocalTime now() {
    return LocalTime.now();
  }
}

代码示例来源:origin: org.actframework/act

@Override
protected LocalTime now() {
  return LocalTime.now();
}

代码示例来源:origin: actframework/actframework

@Override
protected LocalTime now() {
  return LocalTime.now();
}

代码示例来源:origin: org.kuali.kpme/kpme-tk-lm-impl

private List<RoleMember> getRoleMembersInDepartment(
    List<Assignment> assignments, final KPMENamespace namespace) {
  List<RoleMember> roleMembers = new ArrayList<RoleMember>();
  List<KeyValue> groupKeyDepts = new ArrayList<KeyValue>();
  for(Assignment assignment : assignments) {
    groupKeyDepts.add(new ConcreteKeyValue(assignment.getGroupKeyCode(), assignment.getDept()));
  }
  for(KeyValue grpKeyDept : groupKeyDepts) {
    List<RoleMember> roleMembersInDepartment = new ArrayList<RoleMember>();
    roleMembersInDepartment = HrServiceLocator.getKPMERoleService().getRoleMembersInDepartment(namespace.getNamespaceCode(), KPMERole.PAYROLL_PROCESSOR.getRoleName(), grpKeyDept.getValue(), grpKeyDept.getKey(), LocalDate.now().toDateTime(LocalTime.now()), true);
    for(RoleMember roleMember : roleMembersInDepartment) {
      if(!roleMembers.contains(roleMember)) {
        roleMembers.add(roleMember);
      }
    }
  }
  return roleMembers;
}

代码示例来源:origin: actframework/actframework

return sampleDataProviderManager.getSampleData(category, name, LocalDate.class);
} else if (LocalTime.class.isAssignableFrom(classType)) {
  return LocalTime.now();
} else if (Date.class.isAssignableFrom(classType)) {
  return sampleDataProviderManager.getSampleData(category, name, Date.class);

代码示例来源:origin: org.actframework/act

return sampleDataProviderManager.getSampleData(category, name, LocalDate.class);
} else if (LocalTime.class.isAssignableFrom(classType)) {
  return LocalTime.now();
} else if (Date.class.isAssignableFrom(classType)) {
  return sampleDataProviderManager.getSampleData(category, name, Date.class);

相关文章