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

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

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

LocalTime.parse介绍

[英]Parses a LocalTime from the specified string.

This uses ISODateTimeFormat#localTimeParser().
[中]从指定的字符串解析LocalTime。
这将使用ISODateTimeFormat#localTimeParser()。

代码示例

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

  1. /**
  2. * Parses a {@code LocalTime} from the specified string.
  3. * <p>
  4. * This uses {@link ISODateTimeFormat#localTimeParser()}.
  5. *
  6. * @param str the string to parse, not null
  7. * @since 2.0
  8. */
  9. @FromString
  10. public static LocalTime parse(String str) {
  11. return parse(str, ISODateTimeFormat.localTimeParser());
  12. }

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

  1. /**
  2. * Parses a {@code LocalTime} from the specified string.
  3. * <p>
  4. * This uses {@link ISODateTimeFormat#localTimeParser()}.
  5. *
  6. * @param str the string to parse, not null
  7. * @since 2.0
  8. */
  9. @FromString
  10. public static LocalTime parse(String str) {
  11. return parse(str, ISODateTimeFormat.localTimeParser());
  12. }

代码示例来源:origin: prestodb/presto

  1. @Override
  2. public long getLong(int field)
  3. {
  4. checkState(row != null, "No current row");
  5. Column column = columns.get(field);
  6. if (column.getType().getBase() == ColumnType.Base.DATE) {
  7. return Days.daysBetween(new LocalDate(0), LocalDate.parse(row.get(column.getPosition()))).getDays();
  8. }
  9. if (column.getType().getBase() == ColumnType.Base.TIME) {
  10. return LocalTime.parse(row.get(column.getPosition())).getMillisOfDay();
  11. }
  12. if (column.getType().getBase() == ColumnType.Base.INTEGER) {
  13. return parseInt(row.get(column.getPosition()));
  14. }
  15. if (column.getType().getBase() == ColumnType.Base.DECIMAL) {
  16. DecimalParseResult decimalParseResult = Decimals.parse(row.get(column.getPosition()));
  17. return rescale((Long) decimalParseResult.getObject(), decimalParseResult.getType().getScale(), ((DecimalType) columnTypes.get(field)).getScale());
  18. }
  19. return parseLong(row.get(column.getPosition()));
  20. }

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

  1. ByteBuffer.wrap(b),
  2. LocalDate.parse("2014-03-01"),
  3. LocalTime.parse("12:12:12"),
  4. 123456,
  5. DateTime.parse("2014-03-01T12:12:12.321Z"),

代码示例来源:origin: alibaba/fastjson

  1. localDate = localDateTime.toLocalTime();
  2. } else {
  3. localDate = LocalTime.parse(text);

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

  1. public static User generateRandomUser(Random rnd) {
  2. return new User(
  3. generateRandomString(rnd, 50),
  4. rnd.nextBoolean() ? null : rnd.nextInt(),
  5. rnd.nextBoolean() ? null : generateRandomString(rnd, 6),
  6. rnd.nextBoolean() ? null : rnd.nextLong(),
  7. rnd.nextDouble(),
  8. null,
  9. rnd.nextBoolean(),
  10. generateRandomStringList(rnd, 20, 30),
  11. generateRandomBooleanList(rnd, 20),
  12. rnd.nextBoolean() ? null : generateRandomStringList(rnd, 20, 20),
  13. generateRandomColor(rnd),
  14. new HashMap<>(),
  15. generateRandomFixed16(rnd),
  16. generateRandomUnion(rnd),
  17. generateRandomAddress(rnd),
  18. generateRandomBytes(rnd),
  19. LocalDate.parse("2014-03-01"),
  20. LocalTime.parse("12:12:12"),
  21. 123456,
  22. DateTime.parse("2014-03-01T12:12:12.321Z"),
  23. 123456L,
  24. ByteBuffer.wrap(BigDecimal.valueOf(2000, 2).unscaledValue().toByteArray()),
  25. new Fixed2(BigDecimal.valueOf(2000, 2).unscaledValue().toByteArray()));
  26. }

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

  1. @Override
  2. public User map(Tuple3<String, Integer, String> value) {
  3. User user = new User();
  4. user.setName(value.f0);
  5. user.setFavoriteNumber(value.f1);
  6. user.setFavoriteColor(value.f2);
  7. user.setTypeBoolTest(true);
  8. user.setTypeArrayString(Collections.emptyList());
  9. user.setTypeArrayBoolean(Collections.emptyList());
  10. user.setTypeEnum(Colors.BLUE);
  11. user.setTypeMap(Collections.emptyMap());
  12. user.setTypeBytes(ByteBuffer.allocate(10));
  13. user.setTypeDate(LocalDate.parse("2014-03-01"));
  14. user.setTypeTimeMillis(LocalTime.parse("12:12:12"));
  15. user.setTypeTimeMicros(123456);
  16. user.setTypeTimestampMillis(DateTime.parse("2014-03-01T12:12:12.321Z"));
  17. user.setTypeTimestampMicros(123456L);
  18. // 20.00
  19. user.setTypeDecimalBytes(ByteBuffer.wrap(BigDecimal.valueOf(2000, 2).unscaledValue().toByteArray()));
  20. // 20.00
  21. user.setTypeDecimalFixed(new Fixed2(BigDecimal.valueOf(2000, 2).unscaledValue().toByteArray()));
  22. return user;
  23. }
  24. }

代码示例来源:origin: com.alibaba/fastjson

  1. localDate = localDateTime.toLocalTime();
  2. } else {
  3. localDate = LocalTime.parse(text);

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

  1. private void output(final AvroOutputFormat<User> outputFormat) throws IOException {
  2. outputFormat.configure(new Configuration());
  3. outputFormat.open(1, 1);
  4. for (int i = 0; i < 100; i++) {
  5. User user = new User();
  6. user.setName("testUser");
  7. user.setFavoriteNumber(1);
  8. user.setFavoriteColor("blue");
  9. user.setTypeBoolTest(true);
  10. user.setTypeArrayString(Collections.emptyList());
  11. user.setTypeArrayBoolean(Collections.emptyList());
  12. user.setTypeEnum(Colors.BLUE);
  13. user.setTypeMap(Collections.emptyMap());
  14. user.setTypeBytes(ByteBuffer.allocate(10));
  15. user.setTypeDate(LocalDate.parse("2014-03-01"));
  16. user.setTypeTimeMillis(LocalTime.parse("12:12:12"));
  17. user.setTypeTimeMicros(123456);
  18. user.setTypeTimestampMillis(DateTime.parse("2014-03-01T12:12:12.321Z"));
  19. user.setTypeTimestampMicros(123456L);
  20. // 20.00
  21. user.setTypeDecimalBytes(ByteBuffer.wrap(BigDecimal.valueOf(2000, 2).unscaledValue().toByteArray()));
  22. // 20.00
  23. user.setTypeDecimalFixed(new Fixed2(BigDecimal.valueOf(2000, 2).unscaledValue().toByteArray()));
  24. outputFormat.writeRecord(user);
  25. }
  26. outputFormat.close();
  27. }

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

  1. user1.setTypeBytes(ByteBuffer.allocate(10));
  2. user1.setTypeDate(LocalDate.parse("2014-03-01"));
  3. user1.setTypeTimeMillis(LocalTime.parse("12:12:12"));
  4. user1.setTypeTimeMicros(123456);
  5. user1.setTypeTimestampMillis(DateTime.parse("2014-03-01T12:12:12.321Z"));
  6. .setTypeBytes(ByteBuffer.allocate(10))
  7. .setTypeDate(LocalDate.parse("2014-03-01"))
  8. .setTypeTimeMillis(LocalTime.parse("12:12:12"))
  9. .setTypeTimeMicros(123456)
  10. .setTypeTimestampMillis(DateTime.parse("2014-03-01T12:12:12.321Z"))

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

  1. user1.setTypeBytes(ByteBuffer.allocate(10));
  2. user1.setTypeDate(LocalDate.parse("2014-03-01"));
  3. user1.setTypeTimeMillis(LocalTime.parse("12:12:12"));
  4. user1.setTypeTimeMicros(123456);
  5. user1.setTypeTimestampMillis(DateTime.parse("2014-03-01T12:12:12.321Z"));
  6. .setTypeBytes(ByteBuffer.allocate(10))
  7. .setTypeDate(LocalDate.parse("2014-03-01"))
  8. .setTypeTimeMillis(LocalTime.parse("12:12:12"))
  9. .setTypeTimeMicros(123456)
  10. .setTypeTimestampMillis(DateTime.parse("2014-03-01T12:12:12.321Z"))
  11. user.setTypeBytes(ByteBuffer.allocate(10));
  12. user.setTypeDate(LocalDate.parse("2014-03-01"));
  13. user.setTypeTimeMillis(LocalTime.parse("12:12:12"));
  14. user.setTypeTimeMicros(123456);
  15. user.setTypeTimestampMillis(DateTime.parse("2014-03-01T12:12:12.321Z"));

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

  1. user.put("type_bytes", ByteBuffer.allocate(10));
  2. user.put("type_date", LocalDate.parse("2014-03-01"));
  3. user.put("type_time_millis", LocalTime.parse("12:12:12"));
  4. user.put("type_time_micros", 123456);
  5. user.put("type_timestamp_millis", DateTime.parse("2014-03-01T12:12:12.321Z"));

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

  1. .setTypeBytes(ByteBuffer.allocate(10))
  2. .setTypeDate(LocalDate.parse("2014-03-01"))
  3. .setTypeTimeMillis(LocalTime.parse("12:12:12"))
  4. .setTypeTimeMicros(123456)
  5. .setTypeTimestampMillis(DateTime.parse("2014-03-01T12:12:12.321Z"))

代码示例来源:origin: camunda/camunda-bpm-platform

  1. /**
  2. * Parses a {@code LocalTime} from the specified string.
  3. * <p>
  4. * This uses {@link ISODateTimeFormat#localTimeParser()}.
  5. *
  6. * @param str the string to parse, not null
  7. * @since 2.0
  8. */
  9. @FromString
  10. public static LocalTime parse(String str) {
  11. return parse(str, ISODateTimeFormat.localTimeParser());
  12. }

代码示例来源:origin: net.serenity-bdd/serenity-jbehave

  1. @Override
  2. public LocalTime convertValue(String value, Type type) {
  3. return LocalTime.parse(value);
  4. }
  5. }

代码示例来源:origin: org.apache.servicemix.bundles/org.apache.servicemix.bundles.joda-time

  1. /**
  2. * Parses a {@code LocalTime} from the specified string.
  3. * <p>
  4. * This uses {@link ISODateTimeFormat#localTimeParser()}.
  5. *
  6. * @param str the string to parse, not null
  7. * @since 2.0
  8. */
  9. @FromString
  10. public static LocalTime parse(String str) {
  11. return parse(str, ISODateTimeFormat.localTimeParser());
  12. }

代码示例来源:origin: io.virtdata/virtdata-lib-realer

  1. /**
  2. * Parses a {@code LocalTime} from the specified string.
  3. * <p>
  4. * This uses {@link ISODateTimeFormat#localTimeParser()}.
  5. *
  6. * @param str the string to parse, not null
  7. * @since 2.0
  8. */
  9. @FromString
  10. public static LocalTime parse(String str) {
  11. return parse(str, ISODateTimeFormat.localTimeParser());
  12. }

代码示例来源:origin: Nextdoor/bender

  1. /**
  2. * Parses a {@code LocalTime} from the specified string.
  3. * <p>
  4. * This uses {@link ISODateTimeFormat#localTimeParser()}.
  5. *
  6. * @param str the string to parse, not null
  7. * @since 2.0
  8. */
  9. @FromString
  10. public static LocalTime parse(String str) {
  11. return parse(str, ISODateTimeFormat.localTimeParser());
  12. }

代码示例来源:origin: com.ning.billing/killbill-osgi-bundles-jruby

  1. /**
  2. * Parses a {@code LocalTime} from the specified string.
  3. * <p>
  4. * This uses {@link ISODateTimeFormat#localTimeParser()}.
  5. *
  6. * @param str the string to parse, not null
  7. * @since 2.0
  8. */
  9. @FromString
  10. public static LocalTime parse(String str) {
  11. return parse(str, ISODateTimeFormat.localTimeParser());
  12. }

代码示例来源:origin: com.synaptix.toast/toast-tk-adapters

  1. public static Duration parseDurationFromTime(String time) {
  2. if (StringUtils.isEmpty(time)) {
  3. return null;
  4. }
  5. return Duration.millis(LocalTime.parse(time, new DateTimeFormatterBuilder().appendPattern(TimePattern).toFormatter()).getMillisOfDay());
  6. }

相关文章