本文整理匯總了Java中java.time.LocalTime.from方法的典型用法代碼示例。如果您正苦於以下問題:Java LocalTime.from方法的具體用法?Java LocalTime.from怎麽用?Java LocalTime.from使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類java.time.LocalTime
的用法示例。
在下文中一共展示了LocalTime.from方法的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: parseLineToInfo
import java.time.LocalTime; //導入方法依賴的package包/類
private InfoSchema parseLineToInfo(String line, LocalDate localDate) {
String[] columns = line.split(" \\| ");
Matcher matcher = mjlogPattern.matcher(columns[3]);
if (matcher.find()) {
String id = matcher.group(1);
if (this.databaseService.existsIdInINFO(id)) return null;
boolean isSanma = columns[2].substring(0, 1).equals("三");
boolean isTonnan = columns[2].substring(2, 3).equals("南");
int minute = Integer.parseInt(columns[1]);
String[] playerAndScore = columns[4].split(" ");
String[] players = new String[4];
int[] scores = new int[4];
for (int i = 0; i < playerAndScore.length; i++) {
Matcher playerMatcher = playerPattern.matcher(playerAndScore[i]);
if (playerMatcher.find()) {
players[i] = playerMatcher.group(1);
scores[i] = (int) Float.parseFloat(playerMatcher.group(2));
}
}
LocalTime localTime = LocalTime.from(DateTimeFormatter.ofPattern("HH:mm").parse(columns[0]));
LocalDateTime localDateTime = LocalDateTime.of(localDate, localTime);
return new InfoSchema.Builder(id, isSanma, isTonnan, localDateTime,
players[0], players[1], players[2], players[3])
.minute(minute)
.firstScore(scores[0])
.secondScore(scores[1])
.thirdScore(scores[2])
.fourthScore(scores[3])
.build();
}
return null;
}
示例2: factory_from_TemporalAccessor_invalid_noDerive
import java.time.LocalTime; //導入方法依賴的package包/類
@Test(expectedExceptions=DateTimeException.class)
public void factory_from_TemporalAccessor_invalid_noDerive() {
LocalTime.from(LocalDate.of(2007, 7, 15));
}
示例3: factory_from_TemporalAccessor_null
import java.time.LocalTime; //導入方法依賴的package包/類
@Test(expectedExceptions=NullPointerException.class)
public void factory_from_TemporalAccessor_null() {
LocalTime.from((TemporalAccessor) null);
}