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

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

本文整理了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

/**
 * Parses a {@code LocalTime} from the specified string.
 * <p>
 * This uses {@link ISODateTimeFormat#localTimeParser()}.
 * 
 * @param str  the string to parse, not null
 * @since 2.0
 */
@FromString
public static LocalTime parse(String str) {
  return parse(str, ISODateTimeFormat.localTimeParser());
}

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

/**
 * Parses a {@code LocalTime} from the specified string.
 * <p>
 * This uses {@link ISODateTimeFormat#localTimeParser()}.
 * 
 * @param str  the string to parse, not null
 * @since 2.0
 */
@FromString
public static LocalTime parse(String str) {
  return parse(str, ISODateTimeFormat.localTimeParser());
}

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

@Override
public long getLong(int field)
{
  checkState(row != null, "No current row");
  Column column = columns.get(field);
  if (column.getType().getBase() == ColumnType.Base.DATE) {
    return Days.daysBetween(new LocalDate(0), LocalDate.parse(row.get(column.getPosition()))).getDays();
  }
  if (column.getType().getBase() == ColumnType.Base.TIME) {
    return LocalTime.parse(row.get(column.getPosition())).getMillisOfDay();
  }
  if (column.getType().getBase() == ColumnType.Base.INTEGER) {
    return parseInt(row.get(column.getPosition()));
  }
  if (column.getType().getBase() == ColumnType.Base.DECIMAL) {
    DecimalParseResult decimalParseResult = Decimals.parse(row.get(column.getPosition()));
    return rescale((Long) decimalParseResult.getObject(), decimalParseResult.getType().getScale(), ((DecimalType) columnTypes.get(field)).getScale());
  }
  return parseLong(row.get(column.getPosition()));
}

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

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

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

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

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

public static User generateRandomUser(Random rnd) {
  return new User(
      generateRandomString(rnd, 50),
      rnd.nextBoolean() ? null : rnd.nextInt(),
      rnd.nextBoolean() ? null : generateRandomString(rnd, 6),
      rnd.nextBoolean() ? null : rnd.nextLong(),
      rnd.nextDouble(),
      null,
      rnd.nextBoolean(),
      generateRandomStringList(rnd, 20, 30),
      generateRandomBooleanList(rnd, 20),
      rnd.nextBoolean() ? null : generateRandomStringList(rnd, 20, 20),
      generateRandomColor(rnd),
      new HashMap<>(),
      generateRandomFixed16(rnd),
      generateRandomUnion(rnd),
      generateRandomAddress(rnd),
      generateRandomBytes(rnd),
      LocalDate.parse("2014-03-01"),
      LocalTime.parse("12:12:12"),
      123456,
      DateTime.parse("2014-03-01T12:12:12.321Z"),
      123456L,
      ByteBuffer.wrap(BigDecimal.valueOf(2000, 2).unscaledValue().toByteArray()),
      new Fixed2(BigDecimal.valueOf(2000, 2).unscaledValue().toByteArray()));
}

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

@Override
  public User map(Tuple3<String, Integer, String> value) {
    User user = new User();
    user.setName(value.f0);
    user.setFavoriteNumber(value.f1);
    user.setFavoriteColor(value.f2);
    user.setTypeBoolTest(true);
    user.setTypeArrayString(Collections.emptyList());
    user.setTypeArrayBoolean(Collections.emptyList());
    user.setTypeEnum(Colors.BLUE);
    user.setTypeMap(Collections.emptyMap());
    user.setTypeBytes(ByteBuffer.allocate(10));
    user.setTypeDate(LocalDate.parse("2014-03-01"));
    user.setTypeTimeMillis(LocalTime.parse("12:12:12"));
    user.setTypeTimeMicros(123456);
    user.setTypeTimestampMillis(DateTime.parse("2014-03-01T12:12:12.321Z"));
    user.setTypeTimestampMicros(123456L);
    // 20.00
    user.setTypeDecimalBytes(ByteBuffer.wrap(BigDecimal.valueOf(2000, 2).unscaledValue().toByteArray()));
    // 20.00
    user.setTypeDecimalFixed(new Fixed2(BigDecimal.valueOf(2000, 2).unscaledValue().toByteArray()));
    return user;
  }
}

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

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

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

private void output(final AvroOutputFormat<User> outputFormat) throws IOException {
  outputFormat.configure(new Configuration());
  outputFormat.open(1, 1);
  for (int i = 0; i < 100; i++) {
    User user = new User();
    user.setName("testUser");
    user.setFavoriteNumber(1);
    user.setFavoriteColor("blue");
    user.setTypeBoolTest(true);
    user.setTypeArrayString(Collections.emptyList());
    user.setTypeArrayBoolean(Collections.emptyList());
    user.setTypeEnum(Colors.BLUE);
    user.setTypeMap(Collections.emptyMap());
    user.setTypeBytes(ByteBuffer.allocate(10));
    user.setTypeDate(LocalDate.parse("2014-03-01"));
    user.setTypeTimeMillis(LocalTime.parse("12:12:12"));
    user.setTypeTimeMicros(123456);
    user.setTypeTimestampMillis(DateTime.parse("2014-03-01T12:12:12.321Z"));
    user.setTypeTimestampMicros(123456L);
    // 20.00
    user.setTypeDecimalBytes(ByteBuffer.wrap(BigDecimal.valueOf(2000, 2).unscaledValue().toByteArray()));
    // 20.00
    user.setTypeDecimalFixed(new Fixed2(BigDecimal.valueOf(2000, 2).unscaledValue().toByteArray()));
    outputFormat.writeRecord(user);
  }
  outputFormat.close();
}

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

user1.setTypeBytes(ByteBuffer.allocate(10));
user1.setTypeDate(LocalDate.parse("2014-03-01"));
user1.setTypeTimeMillis(LocalTime.parse("12:12:12"));
user1.setTypeTimeMicros(123456);
user1.setTypeTimestampMillis(DateTime.parse("2014-03-01T12:12:12.321Z"));
    .setTypeBytes(ByteBuffer.allocate(10))
    .setTypeDate(LocalDate.parse("2014-03-01"))
    .setTypeTimeMillis(LocalTime.parse("12:12:12"))
    .setTypeTimeMicros(123456)
    .setTypeTimestampMillis(DateTime.parse("2014-03-01T12:12:12.321Z"))

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

user1.setTypeBytes(ByteBuffer.allocate(10));
user1.setTypeDate(LocalDate.parse("2014-03-01"));
user1.setTypeTimeMillis(LocalTime.parse("12:12:12"));
user1.setTypeTimeMicros(123456);
user1.setTypeTimestampMillis(DateTime.parse("2014-03-01T12:12:12.321Z"));
    .setTypeBytes(ByteBuffer.allocate(10))
    .setTypeDate(LocalDate.parse("2014-03-01"))
    .setTypeTimeMillis(LocalTime.parse("12:12:12"))
    .setTypeTimeMicros(123456)
    .setTypeTimestampMillis(DateTime.parse("2014-03-01T12:12:12.321Z"))
  user.setTypeBytes(ByteBuffer.allocate(10));
  user.setTypeDate(LocalDate.parse("2014-03-01"));
  user.setTypeTimeMillis(LocalTime.parse("12:12:12"));
  user.setTypeTimeMicros(123456);
  user.setTypeTimestampMillis(DateTime.parse("2014-03-01T12:12:12.321Z"));

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

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

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

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

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

/**
 * Parses a {@code LocalTime} from the specified string.
 * <p>
 * This uses {@link ISODateTimeFormat#localTimeParser()}.
 * 
 * @param str  the string to parse, not null
 * @since 2.0
 */
@FromString
public static LocalTime parse(String str) {
  return parse(str, ISODateTimeFormat.localTimeParser());
}

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

@Override
  public LocalTime convertValue(String value, Type type) {
    return LocalTime.parse(value);
  }
}

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

/**
 * Parses a {@code LocalTime} from the specified string.
 * <p>
 * This uses {@link ISODateTimeFormat#localTimeParser()}.
 * 
 * @param str  the string to parse, not null
 * @since 2.0
 */
@FromString
public static LocalTime parse(String str) {
  return parse(str, ISODateTimeFormat.localTimeParser());
}

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

/**
 * Parses a {@code LocalTime} from the specified string.
 * <p>
 * This uses {@link ISODateTimeFormat#localTimeParser()}.
 * 
 * @param str  the string to parse, not null
 * @since 2.0
 */
@FromString
public static LocalTime parse(String str) {
  return parse(str, ISODateTimeFormat.localTimeParser());
}

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

/**
 * Parses a {@code LocalTime} from the specified string.
 * <p>
 * This uses {@link ISODateTimeFormat#localTimeParser()}.
 * 
 * @param str  the string to parse, not null
 * @since 2.0
 */
@FromString
public static LocalTime parse(String str) {
  return parse(str, ISODateTimeFormat.localTimeParser());
}

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

/**
 * Parses a {@code LocalTime} from the specified string.
 * <p>
 * This uses {@link ISODateTimeFormat#localTimeParser()}.
 * 
 * @param str  the string to parse, not null
 * @since 2.0
 */
@FromString
public static LocalTime parse(String str) {
  return parse(str, ISODateTimeFormat.localTimeParser());
}

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

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

相关文章