本文整理汇总了Java中java.time.format.DecimalStyle类的典型用法代码示例。如果您正苦于以下问题:Java DecimalStyle类的具体用法?Java DecimalStyle怎么用?Java DecimalStyle使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
DecimalStyle类属于java.time.format包,在下文中一共展示了DecimalStyle类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。
示例1: test_ParseText
import java.time.format.DecimalStyle; //导入依赖的package包/类
@Test(dataProvider="preferredZones")
public void test_ParseText(String expected, String text, Set<ZoneId> preferred, Locale locale, TextStyle style) {
DateTimeFormatter fmt = new DateTimeFormatterBuilder().appendZoneText(style, preferred)
.toFormatter(locale)
.withDecimalStyle(DecimalStyle.of(locale));
String ret = fmt.parse(text, TemporalQueries.zone()).getId();
System.out.printf("[%-5s %s] %24s -> %s(%s)%n",
locale.toString(),
style == TextStyle.FULL ? " full" :"short",
text, ret, expected);
assertEquals(ret, expected);
}
开发者ID:lambdalab-mirror,项目名称:jdk8u-jdk,代码行数:17,代码来源:TestZoneTextPrinterParser.java
示例2: test_of_Locale
import java.time.format.DecimalStyle; //导入依赖的package包/类
@Test
public void test_of_Locale() {
DecimalStyle loc1 = DecimalStyle.of(Locale.CANADA);
assertEquals(loc1.getZeroDigit(), '0');
assertEquals(loc1.getPositiveSign(), '+');
assertEquals(loc1.getNegativeSign(), '-');
assertEquals(loc1.getDecimalSeparator(), '.');
}
开发者ID:lambdalab-mirror,项目名称:jdk8u-jdk,代码行数:9,代码来源:TCKDecimalStyle.java
示例3: test_toFormat_parseObject_StringParsePosition_invalidPosition_tooSmall
import java.time.format.DecimalStyle; //导入依赖的package包/类
@Test
public void test_toFormat_parseObject_StringParsePosition_invalidPosition_tooSmall() throws Exception {
// SimpleDateFormat throws StringIndexOutOfBoundException
DateTimeFormatter dtf = fmt.withLocale(Locale.ENGLISH).withDecimalStyle(DecimalStyle.STANDARD);
ParsePosition pos = new ParsePosition(-1);
Format test = dtf.toFormat();
assertNull(test.parseObject("ONE30", pos));
assertTrue(pos.getErrorIndex() >= 0);
}
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:10,代码来源:TCKDateTimeFormatter.java
示例4: test_toFormat_parseObject_StringParsePosition_nullParsePosition
import java.time.format.DecimalStyle; //导入依赖的package包/类
@Test(expectedExceptions=NullPointerException.class)
public void test_toFormat_parseObject_StringParsePosition_nullParsePosition() throws Exception {
// SimpleDateFormat has this behavior
DateTimeFormatter test = fmt.withLocale(Locale.ENGLISH).withDecimalStyle(DecimalStyle.STANDARD);
Format format = test.toFormat();
format.parseObject("ONE30", (ParsePosition) null);
}
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:8,代码来源:TCKDateTimeFormatter.java
示例5: test_equalsHashCode3
import java.time.format.DecimalStyle; //导入依赖的package包/类
@Test
public void test_equalsHashCode3() {
DecimalStyle a = DecimalStyle.STANDARD.withZeroDigit('A');
DecimalStyle b = DecimalStyle.STANDARD.withDecimalSeparator('A');
assertEquals(a.equals(b), false);
assertEquals(b.equals(a), false);
}
开发者ID:lambdalab-mirror,项目名称:jdk8u-jdk,代码行数:8,代码来源:TCKDecimalStyle.java
示例6: test_toFormat_parseObject_String_parseError
import java.time.format.DecimalStyle; //导入依赖的package包/类
@Test(expectedExceptions=ParseException.class)
public void test_toFormat_parseObject_String_parseError() throws Exception {
DateTimeFormatter test = fmt.withLocale(Locale.ENGLISH).withDecimalStyle(DecimalStyle.STANDARD);
Format format = test.toFormat();
try {
format.parseObject("ONEXXX");
} catch (ParseException ex) {
assertEquals(ex.getMessage().contains("ONEXXX"), true);
assertEquals(ex.getErrorOffset(), 3);
throw ex;
}
}
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:13,代码来源:TCKDateTimeFormatter.java
示例7: test_print_TemporalAppendable
import java.time.format.DecimalStyle; //导入依赖的package包/类
@Test
public void test_print_TemporalAppendable() throws Exception {
DateTimeFormatter test = fmt.withLocale(Locale.ENGLISH).withDecimalStyle(DecimalStyle.STANDARD);
StringBuilder buf = new StringBuilder();
test.formatTo(LocalDate.of(2008, 6, 30), buf);
assertEquals(buf.toString(), "ONE30");
}
开发者ID:lambdalab-mirror,项目名称:jdk8u-jdk,代码行数:8,代码来源:TCKDateTimeFormatter.java
示例8: test_parse_CharSequence
import java.time.format.DecimalStyle; //导入依赖的package包/类
@Test
public void test_parse_CharSequence() {
DateTimeFormatter test = fmt.withLocale(Locale.ENGLISH).withDecimalStyle(DecimalStyle.STANDARD);
TemporalAccessor result = test.parse("ONE30");
assertEquals(result.isSupported(DAY_OF_MONTH), true);
assertEquals(result.getLong(DAY_OF_MONTH), 30L);
assertEquals(result.isSupported(HOUR_OF_DAY), false);
}
开发者ID:lambdalab-mirror,项目名称:jdk8u-jdk,代码行数:9,代码来源:TCKDateTimeFormatter.java
示例9: test_parse_CharSequence_ParsePosition
import java.time.format.DecimalStyle; //导入依赖的package包/类
@Test
public void test_parse_CharSequence_ParsePosition() {
DateTimeFormatter test = fmt.withLocale(Locale.ENGLISH).withDecimalStyle(DecimalStyle.STANDARD);
ParsePosition pos = new ParsePosition(3);
TemporalAccessor result = test.parse("XXXONE30XXX", pos);
assertEquals(pos.getIndex(), 8);
assertEquals(pos.getErrorIndex(), -1);
assertEquals(result.isSupported(DAY_OF_MONTH), true);
assertEquals(result.getLong(DAY_OF_MONTH), 30L);
assertEquals(result.isSupported(HOUR_OF_DAY), false);
}
开发者ID:lambdalab-mirror,项目名称:jdk8u-jdk,代码行数:12,代码来源:TCKDateTimeFormatter.java
示例10: test_toFormat_parseObject_String_parseErrorLongText
import java.time.format.DecimalStyle; //导入依赖的package包/类
@Test(expectedExceptions=ParseException.class)
public void test_toFormat_parseObject_String_parseErrorLongText() throws Exception {
DateTimeFormatter test = fmt.withLocale(Locale.ENGLISH).withDecimalStyle(DecimalStyle.STANDARD);
Format format = test.toFormat();
try {
format.parseObject("ONEXXX67890123456789012345678901234567890123456789012345678901234567890123456789");
} catch (DateTimeParseException ex) {
assertEquals(ex.getMessage().contains("ONEXXX6789012345678901234567890123456789012345678901234567890123..."), true);
assertEquals(ex.getParsedString(), "ONEXXX67890123456789012345678901234567890123456789012345678901234567890123456789");
assertEquals(ex.getErrorIndex(), 3);
throw ex;
}
}
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:14,代码来源:TCKDateTimeFormatter.java
示例11: test_parseBest_String_parseIncomplete
import java.time.format.DecimalStyle; //导入依赖的package包/类
@Test(expectedExceptions=DateTimeParseException.class)
public void test_parseBest_String_parseIncomplete() throws Exception {
DateTimeFormatter test = fmt.withLocale(Locale.ENGLISH).withDecimalStyle(DecimalStyle.STANDARD);
try {
test.parseBest("ONE30SomethingElse", ZonedDateTime::from, LocalDate::from);
} catch (DateTimeParseException ex) {
assertEquals(ex.getMessage().contains("could not be parsed"), true);
assertEquals(ex.getMessage().contains("ONE30SomethingElse"), true);
assertEquals(ex.getParsedString(), "ONE30SomethingElse");
assertEquals(ex.getErrorIndex(), 5);
throw ex;
}
}
开发者ID:lambdalab-mirror,项目名称:jdk8u-jdk,代码行数:14,代码来源:TCKDateTimeFormatter.java
示例12: test_parseLocalizedText
import java.time.format.DecimalStyle; //导入依赖的package包/类
@Test(dataProvider="format_data")
public void test_parseLocalizedText(Chronology chrono, Locale formatLocale, Locale numberingLocale,
ChronoLocalDate expected, String text) {
DateTimeFormatter dtf = DateTimeFormatter.ofLocalizedDate(FormatStyle.FULL)
.withChronology(chrono).withLocale(formatLocale)
.withDecimalStyle(DecimalStyle.of(numberingLocale));
TemporalAccessor temporal = dtf.parse(text);
ChronoLocalDate date = chrono.date(temporal);
assertEquals(date, expected);
}
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:11,代码来源:TestNonIsoFormatter.java
示例13: test_parseUnresolved_StringParsePosition
import java.time.format.DecimalStyle; //导入依赖的package包/类
@Test
public void test_parseUnresolved_StringParsePosition() {
DateTimeFormatter test = fmt.withLocale(Locale.ENGLISH).withDecimalStyle(DecimalStyle.STANDARD);
ParsePosition pos = new ParsePosition(0);
TemporalAccessor result = test.parseUnresolved("ONE30XXX", pos);
assertEquals(pos.getIndex(), 5);
assertEquals(pos.getErrorIndex(), -1);
assertEquals(result.getLong(DAY_OF_MONTH), 30L);
}
开发者ID:lambdalab-mirror,项目名称:jdk8u-jdk,代码行数:10,代码来源:TCKDateTimeFormatter.java
示例14: test_parseUnresolved_StringParsePosition_parseError
import java.time.format.DecimalStyle; //导入依赖的package包/类
@Test
public void test_parseUnresolved_StringParsePosition_parseError() {
DateTimeFormatter test = fmt.withLocale(Locale.ENGLISH).withDecimalStyle(DecimalStyle.STANDARD);
ParsePosition pos = new ParsePosition(0);
TemporalAccessor result = test.parseUnresolved("ONEXXX", pos);
assertEquals(pos.getIndex(), 0);
assertEquals(pos.getErrorIndex(), 3);
assertEquals(result, null);
}
开发者ID:lambdalab-mirror,项目名称:jdk8u-jdk,代码行数:10,代码来源:TCKDateTimeFormatter.java
示例15: test_formatLocalizedDate
import java.time.format.DecimalStyle; //导入依赖的package包/类
@Test(dataProvider="format_data")
public void test_formatLocalizedDate(Chronology chrono, Locale formatLocale, Locale numberingLocale,
ChronoLocalDate date, String expected) {
DateTimeFormatter dtf = DateTimeFormatter.ofLocalizedDate(FormatStyle.FULL)
.withChronology(chrono).withLocale(formatLocale)
.withDecimalStyle(DecimalStyle.of(numberingLocale));
String text = dtf.format(date);
assertEquals(text, expected);
}
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:10,代码来源:TestNonIsoFormatter.java
示例16: test_toFormat_format
import java.time.format.DecimalStyle; //导入依赖的package包/类
@Test
public void test_toFormat_format() throws Exception {
DateTimeFormatter test = fmt.withLocale(Locale.ENGLISH).withDecimalStyle(DecimalStyle.STANDARD);
Format format = test.toFormat();
String result = format.format(LocalDate.of(2008, 6, 30));
assertEquals(result, "ONE30");
}
开发者ID:lambdalab-mirror,项目名称:jdk8u-jdk,代码行数:8,代码来源:TCKDateTimeFormatter.java
示例17: test_toFormat_parseObject_String
import java.time.format.DecimalStyle; //导入依赖的package包/类
@Test
public void test_toFormat_parseObject_String() throws Exception {
DateTimeFormatter test = fmt.withLocale(Locale.ENGLISH).withDecimalStyle(DecimalStyle.STANDARD);
Format format = test.toFormat();
TemporalAccessor result = (TemporalAccessor) format.parseObject("ONE30");
assertEquals(result.isSupported(DAY_OF_MONTH), true);
assertEquals(result.getLong(DAY_OF_MONTH), 30L);
}
开发者ID:lambdalab-mirror,项目名称:jdk8u-jdk,代码行数:9,代码来源:TCKDateTimeFormatter.java
示例18: test_toFormat_parseObject_StringParsePosition_parseError
import java.time.format.DecimalStyle; //导入依赖的package包/类
@Test
public void test_toFormat_parseObject_StringParsePosition_parseError() throws Exception {
DateTimeFormatter test = fmt.withLocale(Locale.ENGLISH).withDecimalStyle(DecimalStyle.STANDARD);
Format format = test.toFormat();
ParsePosition pos = new ParsePosition(0);
TemporalAccessor result = (TemporalAccessor) format.parseObject("ONEXXX", pos);
assertEquals(pos.getIndex(), 0); // TODO: is this right?
assertEquals(pos.getErrorIndex(), 3);
assertEquals(result, null);
}
开发者ID:lambdalab-mirror,项目名称:jdk8u-jdk,代码行数:11,代码来源:TCKDateTimeFormatter.java
示例19: test_toFormat_parseObject_StringParsePosition_nullString
import java.time.format.DecimalStyle; //导入依赖的package包/类
@Test(expectedExceptions=NullPointerException.class)
public void test_toFormat_parseObject_StringParsePosition_nullString() throws Exception {
// SimpleDateFormat has this behavior
DateTimeFormatter test = fmt.withLocale(Locale.ENGLISH).withDecimalStyle(DecimalStyle.STANDARD);
Format format = test.toFormat();
ParsePosition pos = new ParsePosition(0);
format.parseObject((String) null, pos);
}
开发者ID:lambdalab-mirror,项目名称:jdk8u-jdk,代码行数:9,代码来源:TCKDateTimeFormatter.java
示例20: test_withLocale_same
import java.time.format.DecimalStyle; //导入依赖的package包/类
@Test
public void test_withLocale_same() throws Exception {
DateTimeFormatter base =
new DateTimeFormatterBuilder().appendLiteral("ONE")
.appendValue(DAY_OF_MONTH, 1, 2, SignStyle.NOT_NEGATIVE)
.toFormatter(Locale.ENGLISH)
.withDecimalStyle(DecimalStyle.STANDARD);
DateTimeFormatter test = base.withLocale(Locale.ENGLISH);
assertSame(test, base);
}
开发者ID:lambdalab-mirror,项目名称:jdk8u-jdk,代码行数:11,代码来源:TestDateTimeFormatter.java
注:本文中的java.time.format.DecimalStyle类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论