本文整理汇总了Java中java.time.temporal.TemporalQuery类的典型用法代码示例。如果您正苦于以下问题:Java TemporalQuery类的具体用法?Java TemporalQuery怎么用?Java TemporalQuery使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
TemporalQuery类属于java.time.temporal包,在下文中一共展示了TemporalQuery类的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: toDateObject
import java.time.temporal.TemporalQuery; //导入依赖的package包/类
private <T> T toDateObject(String raw, TemporalQuery<T> from) {
if (raw.contains(":59:60")) {
// ISO_INSTANT doesn't crash on leap seconds
TemporalAccessor parse = DateTimeFormatter.ISO_INSTANT.parse(raw);
if (parse.query(DateTimeFormatter.parsedLeapSecond())) {
// lazy: push back the second instead
logger.warn("Exciting! Saw a leap second, shifting the date back 1s, {}", raw);
return ISO.parse(raw.replace(":59:60", ":59:59"), from);
}
}
return ISO.parse(raw, from);
}
示例2: getValue
import java.time.temporal.TemporalQuery; //导入依赖的package包/类
/**
* Gets a value using a query.
*
* @param query the query to use, not null
* @return the result, null if not found and optional is true
* @throws DateTimeException if the type is not available and the section is not optional
*/
<R> R getValue(TemporalQuery<R> query) {
R result = temporal.query(query);
if (result == null && optional == 0) {
throw new DateTimeException("Unable to extract value: " + temporal.getClass());
}
return result;
}
示例3: basicTest_query
import java.time.temporal.TemporalQuery; //导入依赖的package包/类
@Test
public void basicTest_query() {
for (TemporalAccessor sample : samples()) {
assertEquals(sample.query(new TemporalQuery<String>() {
@Override
public String queryFrom(TemporalAccessor temporal) {
return "foo";
}
}), "foo");
}
}
示例4: getValue
import java.time.temporal.TemporalQuery; //导入依赖的package包/类
/**
* Gets a value using a query.
*
* @param query the query to use, not null
* @return the result, null if not found and optional is true
* @throws DateTimeException if the type is not available and the section is not optional
*/
<R> R getValue(TemporalQuery<R> query) {
R result = temporal.query(query);
if (result == null && optional == 0) {
throw new DateTimeException("Unable to extract " +
query + " from temporal " + temporal);
}
return result;
}
示例5: ClassicFormat
import java.time.temporal.TemporalQuery; //导入依赖的package包/类
/** Constructor. */
public ClassicFormat(DateTimeFormatter formatter, TemporalQuery<?> parseType) {
this.formatter = formatter;
this.parseType = parseType;
}
示例6: ZoneIdPrinterParser
import java.time.temporal.TemporalQuery; //导入依赖的package包/类
ZoneIdPrinterParser(TemporalQuery<ZoneId> query, String description) {
this.query = query;
this.description = description;
}
示例7: test_query
import java.time.temporal.TemporalQuery; //导入依赖的package包/类
@Test(dataProvider="query")
public <T> void test_query(TemporalAccessor temporal, TemporalQuery<T> query, T expected) {
assertEquals(temporal.query(query), expected);
}
示例8: test_queryFrom
import java.time.temporal.TemporalQuery; //导入依赖的package包/类
@Test(dataProvider="query")
public <T> void test_queryFrom(TemporalAccessor temporal, TemporalQuery<T> query, T expected) {
assertEquals(query.queryFrom(temporal), expected);
}
示例9: test_parse_Query_String_nullRule
import java.time.temporal.TemporalQuery; //导入依赖的package包/类
@Test(expectedExceptions=NullPointerException.class)
public void test_parse_Query_String_nullRule() throws Exception {
DateTimeFormatter test = fmt.withLocale(Locale.ENGLISH).withDecimalStyle(DecimalStyle.STANDARD);
test.parse("30", (TemporalQuery<?>) null);
}
示例10: test_parseBest_String_nullRules
import java.time.temporal.TemporalQuery; //导入依赖的package包/类
@Test(expectedExceptions=NullPointerException.class)
public void test_parseBest_String_nullRules() throws Exception {
DateTimeFormatter test = fmt.withLocale(Locale.ENGLISH).withDecimalStyle(DecimalStyle.STANDARD);
test.parseBest("30", (TemporalQuery<?>[]) null);
}
示例11: test_parseBest_String_zeroRules
import java.time.temporal.TemporalQuery; //导入依赖的package包/类
@Test(expectedExceptions=IllegalArgumentException.class)
public void test_parseBest_String_zeroRules() throws Exception {
DateTimeFormatter test = fmt.withLocale(Locale.ENGLISH).withDecimalStyle(DecimalStyle.STANDARD);
test.parseBest("30", new TemporalQuery<?>[0]);
}