本文整理汇总了Java中java.util.Locale.JAPAN属性的典型用法代码示例。如果您正苦于以下问题:Java Locale.JAPAN属性的具体用法?Java Locale.JAPAN怎么用?Java Locale.JAPAN使用的例子?那么, 这里精选的属性代码示例或许可以为您提供帮助。您也可以进一步了解该属性所在类java.util.Locale
的用法示例。
在下文中一共展示了Locale.JAPAN属性的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: switchLanguage
protected void switchLanguage(String lang) {
Resources resources = getResources();
Configuration configuration = resources.getConfiguration();
DisplayMetrics displayMetrics = resources.getDisplayMetrics();
switch (lang) {
case "zh":
configuration.locale = Locale.TAIWAN;
break;
case "ja":
configuration.locale = Locale.JAPAN;
break;
default:
configuration.locale = Locale.ENGLISH;
break;
}
resources.updateConfiguration(configuration, displayMetrics);
/* 避免重複寫入
MainApplication.writeSetting("uiLang", lang);
//*/
}
示例2: data_date
@DataProvider(name="date")
Object[][] data_date() {
return new Object[][] {
{LocalDate.of(2012, 6, 30), FormatStyle.SHORT, DateFormat.SHORT, Locale.UK},
{LocalDate.of(2012, 6, 30), FormatStyle.SHORT, DateFormat.SHORT, Locale.US},
{LocalDate.of(2012, 6, 30), FormatStyle.SHORT, DateFormat.SHORT, Locale.FRANCE},
{LocalDate.of(2012, 6, 30), FormatStyle.SHORT, DateFormat.SHORT, Locale.JAPAN},
{LocalDate.of(2012, 6, 30), FormatStyle.MEDIUM, DateFormat.MEDIUM, Locale.UK},
{LocalDate.of(2012, 6, 30), FormatStyle.MEDIUM, DateFormat.MEDIUM, Locale.US},
{LocalDate.of(2012, 6, 30), FormatStyle.MEDIUM, DateFormat.MEDIUM, Locale.FRANCE},
{LocalDate.of(2012, 6, 30), FormatStyle.MEDIUM, DateFormat.MEDIUM, Locale.JAPAN},
{LocalDate.of(2012, 6, 30), FormatStyle.LONG, DateFormat.LONG, Locale.UK},
{LocalDate.of(2012, 6, 30), FormatStyle.LONG, DateFormat.LONG, Locale.US},
{LocalDate.of(2012, 6, 30), FormatStyle.LONG, DateFormat.LONG, Locale.FRANCE},
{LocalDate.of(2012, 6, 30), FormatStyle.LONG, DateFormat.LONG, Locale.JAPAN},
{LocalDate.of(2012, 6, 30), FormatStyle.FULL, DateFormat.FULL, Locale.UK},
{LocalDate.of(2012, 6, 30), FormatStyle.FULL, DateFormat.FULL, Locale.US},
{LocalDate.of(2012, 6, 30), FormatStyle.FULL, DateFormat.FULL, Locale.FRANCE},
{LocalDate.of(2012, 6, 30), FormatStyle.FULL, DateFormat.FULL, Locale.JAPAN},
};
}
示例3: data_time
@DataProvider(name="time")
Object[][] data_time() {
return new Object[][] {
{LocalTime.of(11, 30), FormatStyle.SHORT, DateFormat.SHORT, Locale.UK},
{LocalTime.of(11, 30), FormatStyle.SHORT, DateFormat.SHORT, Locale.US},
{LocalTime.of(11, 30), FormatStyle.SHORT, DateFormat.SHORT, Locale.FRANCE},
{LocalTime.of(11, 30), FormatStyle.SHORT, DateFormat.SHORT, Locale.JAPAN},
{LocalTime.of(11, 30), FormatStyle.MEDIUM, DateFormat.MEDIUM, Locale.UK},
{LocalTime.of(11, 30), FormatStyle.MEDIUM, DateFormat.MEDIUM, Locale.US},
{LocalTime.of(11, 30), FormatStyle.MEDIUM, DateFormat.MEDIUM, Locale.FRANCE},
{LocalTime.of(11, 30), FormatStyle.MEDIUM, DateFormat.MEDIUM, Locale.JAPAN},
// these localized patterns include "z" which isn't available from LocalTime
// {LocalTime.of(11, 30), FormatStyle.LONG, DateFormat.LONG, Locale.UK},
// {LocalTime.of(11, 30), FormatStyle.LONG, DateFormat.LONG, Locale.US},
// {LocalTime.of(11, 30), FormatStyle.LONG, DateFormat.LONG, Locale.FRANCE},
// {LocalTime.of(11, 30), FormatStyle.LONG, DateFormat.LONG, Locale.JAPAN},
//
// {LocalTime.of(11, 30), FormatStyle.FULL, DateFormat.FULL, Locale.UK},
// {LocalTime.of(11, 30), FormatStyle.FULL, DateFormat.FULL, Locale.US},
// {LocalTime.of(11, 30), FormatStyle.FULL, DateFormat.FULL, Locale.FRANCE},
// {LocalTime.of(11, 30), FormatStyle.FULL, DateFormat.FULL, Locale.JAPAN},
};
}
示例4: testGetDataList
@Test
public void testGetDataList() throws Exception {
//given
int firstRow = 0;
int numRows = 10;
int totalCount = 1;
List<POSubscription> expectedList = prepareList();
Response resp = new Response(expectedList);
when(subscriptionsService.getMySubscriptionsWithFiltering(any(PaginationFullTextFilter.class))).thenReturn(resp);
when(subscriptionsService.getMySubscriptionsSizeWithFiltering(any(PaginationFullTextFilter.class))).thenReturn(totalCount);
ArrangeableState arrangeable = new ArrangeableState() {
@Override
public List<FilterField> getFilterFields() {
return Collections.emptyList();
}
@Override
public List<SortField> getSortFields() {
return Collections.emptyList();
}
@Override
public Locale getLocale() {
return Locale.JAPAN;
}
};
when(model.getArrangeable()).thenReturn(arrangeable);
model.setSelectedSubscription(new POSubscription(new VOSubscription()));
//when
List<POSubscription> result = model.getDataList(firstRow, numRows,
Collections.<FilterField>emptyList(), Collections.<SortField>emptyList(), new Object());
//then
assertArrayEquals(expectedList.toArray(), result.toArray());
assertEquals(model.getTotalCount(), totalCount);
}
示例5: testGetDataListFilteredOut
@Test
public void testGetDataListFilteredOut() throws Exception {
//given
int firstRow = 0;
int numRows = 10;
int totalCount = 1;
List<POSubscription> expectedList = prepareList();
Response resp = new Response(expectedList);
when(subscriptionsService.getMySubscriptionsWithFiltering(any(PaginationFullTextFilter.class))).thenReturn(resp);
when(subscriptionsService.getMySubscriptionsSizeWithFiltering(any(PaginationFullTextFilter.class))).thenReturn(totalCount);
ArrangeableState arrangeable = new ArrangeableState() {
@Override
public List<FilterField> getFilterFields() {
return Collections.emptyList();
}
@Override
public List<SortField> getSortFields() {
return Collections.emptyList();
}
@Override
public Locale getLocale() {
return Locale.JAPAN;
}
};
when(model.getArrangeable()).thenReturn(arrangeable);
VOSubscription voSubscription = new VOSubscription();
voSubscription.setKey(1001L);
model.setSelectedSubscription(new POSubscription(voSubscription));
//when
List<POSubscription> result = model.getDataList(firstRow, numRows,
Collections.<FilterField>emptyList(), Collections.<SortField>emptyList(), new Object());
//then
assertArrayEquals(expectedList.toArray(), result.toArray());
assertEquals(model.getTotalCount(), totalCount);
}
示例6: testGetDataListReturnsDetails
@Test
public void testGetDataListReturnsDetails() throws Exception {
//given
int firstRow = 0;
int numRows = 10;
int totalCount = 1;
List<POSubscription> expectedList = prepareList();
Response resp = new Response(expectedList);
when(subscriptionsService.getMySubscriptionsWithFiltering(any(PaginationFullTextFilter.class))).thenReturn(resp);
when(subscriptionsService.getMySubscriptionsSizeWithFiltering(any(PaginationFullTextFilter.class))).thenReturn(totalCount);
doReturn(expectedList.get(0)).when(subscriptionsService).getMySubscriptionDetails(expectedList.get(0).getKey());
ArrangeableState arrangeable = new ArrangeableState() {
@Override
public List<FilterField> getFilterFields() {
return Collections.emptyList();
}
@Override
public List<SortField> getSortFields() {
return Collections.emptyList();
}
@Override
public Locale getLocale() {
return Locale.JAPAN;
}
};
when(model.getArrangeable()).thenReturn(arrangeable);
model.setSelectedSubscription(new POSubscription(new VOSubscription()));
//when
List<POSubscription> result = model.getDataList(firstRow, numRows,
Collections.<FilterField>emptyList(), Collections.<SortField>emptyList(), new Object());
//then
assertArrayEquals(expectedList.toArray(), result.toArray());
assertEquals(model.getTotalCount(), totalCount);
}
示例7: testGetRowTotalCount
@Test
public void testGetRowTotalCount() throws Exception {
//given
int totalCount = 1;
List<POSubscription> expectedList = prepareList();
Response resp = new Response(expectedList);
when(subscriptionsService.getMySubscriptionsWithFiltering(any(PaginationFullTextFilter.class))).thenReturn(resp);
when(subscriptionsService.getMySubscriptionsSizeWithFiltering(any(PaginationFullTextFilter.class))).thenReturn(totalCount);
ArrangeableState arrangeable = new ArrangeableState() {
@Override
public List<FilterField> getFilterFields() {
return Collections.emptyList();
}
@Override
public List<SortField> getSortFields() {
return Collections.emptyList();
}
@Override
public Locale getLocale() {
return Locale.JAPAN;
}
};
when(model.getArrangeable()).thenReturn(arrangeable);
model.setSelectedSubscription(new POSubscription(new VOSubscription()));
//when
int result = model.getTotalCount();
//then
assertEquals(result, totalCount);
}
示例8: testGetDataListNullSelected
@Test
public void testGetDataListNullSelected() throws Exception {
//given
int firstRow = 0;
int numRows = 10;
int totalCount = 1;
List<POSubscription> expectedList = prepareList();
Response resp = new Response(expectedList);
POSubscription selectedSubscription = mock(POSubscription.class);
when(selectedSubscription.getKey()).thenReturn(-1L);
when(subscriptionsService.getMySubscriptionsWithFiltering(any(PaginationFullTextFilter.class))).thenReturn(resp);
when(subscriptionsService.getMySubscriptionsSizeWithFiltering(any(PaginationFullTextFilter.class))).thenReturn(totalCount);
when(subscriptionsService.getMySubscriptionDetails(-1L)).thenReturn(null);
ArrangeableState arrangeable = new ArrangeableState() {
@Override
public List<FilterField> getFilterFields() {
return Collections.emptyList();
}
@Override
public List<SortField> getSortFields() {
return Collections.emptyList();
}
@Override
public Locale getLocale() {
return Locale.JAPAN;
}
};
when(model.getArrangeable()).thenReturn(arrangeable);
//when
List<POSubscription> result = model.getDataList(firstRow, numRows,
Collections.<FilterField>emptyList(), Collections.<SortField>emptyList(), new Object());
//then
assertArrayEquals(expectedList.toArray(), result.toArray());
assertEquals(model.getTotalCount(), totalCount);
assertNull(model.getSelectedSubscription());
assertNull(model.getSelectedSubscriptionId());
}
示例9: testGetDataList
@Test
public void testGetDataList() throws Exception {
//given
int firstRow = 0;
int numRows = 10;
int totalCount = 1;
List<POSubscriptionAndCustomer> expectedList = prepareList();
Response resp = new Response(expectedList);
when(subscriptionsService.getSubscriptionsAndCustomersForManagers(any(Pagination.class))).thenReturn(resp);
when(subscriptionsService.getSubscriptionsAndCustomersForManagersSize(any(Pagination.class))).thenReturn(totalCount);
ArrangeableState arrangeable = new ArrangeableState() {
@Override
public List<FilterField> getFilterFields() {
return Collections.emptyList();
}
@Override
public List<SortField> getSortFields() {
return Collections.emptyList();
}
@Override
public Locale getLocale() {
return Locale.JAPAN;
}
};
when(beanUnderTheTest.getArrangeable()).thenReturn(arrangeable);
doNothing().when(beanUnderTheTest).applyFilters(anyList(), any(Pagination.class));
doNothing().when(beanUnderTheTest).decorateWithLocalizedStatuses(any(Pagination.class));
beanUnderTheTest.setSubscriptionsService(subscriptionsService);
//when
List<POSubscriptionAndCustomer> result = beanUnderTheTest.getDataList(firstRow, numRows,
Collections.<FilterField>emptyList(), Collections.<SortField>emptyList(), new Object());
//then
assertArrayEquals(expectedList.toArray(), result.toArray());
assertEquals(beanUnderTheTest.getTotalCount(), totalCount);
}
示例10: testGetTotalCount
@Test
public void testGetTotalCount() throws Exception {
//given
beanUnderTheTest.setTotalCount(-1);
when(subscriptionsService.getSubscriptionsAndCustomersForManagersSize(any(Pagination.class))).thenReturn(2);
beanUnderTheTest.setSubscriptionsService(subscriptionsService);
ArrangeableState arrangeable = new ArrangeableState() {
@Override
public List<FilterField> getFilterFields() {
return Collections.emptyList();
}
@Override
public List<SortField> getSortFields() {
return Collections.emptyList();
}
@Override
public Locale getLocale() {
return Locale.JAPAN;
}
};
when(beanUnderTheTest.getArrangeable()).thenReturn(arrangeable);
doNothing().when(beanUnderTheTest).applyFilters(anyList(), any(Pagination.class));
//when
int totalCount = beanUnderTheTest.getTotalCount();
//then
assertEquals(2, totalCount);
verify(subscriptionsService, atLeastOnce()).getSubscriptionsAndCustomersForManagersSize(any(Pagination.class));
}
示例11: testGetSubscriptionsListSize
@Test
public void testGetSubscriptionsListSize() throws Exception {
//given
when(beanUnderTheTest.getCachedList()).thenReturn(prepareList());
ArrangeableState arrangeable = new ArrangeableState() {
@Override
public List<FilterField> getFilterFields() {
return Collections.emptyList();
}
@Override
public List<SortField> getSortFields() {
return Collections.emptyList();
}
@Override
public Locale getLocale() {
return Locale.JAPAN;
}
};
when(beanUnderTheTest.getArrangeable()).thenReturn(arrangeable);
doNothing().when(beanUnderTheTest).applyFilters(anyList(), any(Pagination.class));
when(subscriptionsService.getSubscriptionsAndCustomersForManagersSize(any(Pagination.class))).thenReturn(1);
beanUnderTheTest.setSubscriptionsService(subscriptionsService);
//when
int totalCount = beanUnderTheTest.getTotalCount();
//then
assertEquals(1,totalCount);
}
示例12: isSharedFlyweight
private static boolean isSharedFlyweight(Object obj) {
if (obj == null) {
return true;
}
if (obj == Boolean.TRUE || obj == Boolean.FALSE) {
return true;
}
if (/* obj == Locale.ROOT || *//* Java 6 */
obj == Locale.ENGLISH || obj == Locale.FRENCH || obj == Locale.GERMAN || obj == Locale.ITALIAN
|| obj == Locale.JAPANESE || obj == Locale.KOREAN || obj == Locale.CHINESE
|| obj == Locale.SIMPLIFIED_CHINESE || obj == Locale.TRADITIONAL_CHINESE || obj == Locale.FRANCE
|| obj == Locale.GERMANY || obj == Locale.ITALY || obj == Locale.JAPAN || obj == Locale.KOREA
|| obj == Locale.CHINA || obj == Locale.PRC || obj == Locale.TAIWAN || obj == Locale.UK
|| obj == Locale.US || obj == Locale.CANADA || obj == Locale.CANADA_FRENCH) {
return true;
}
if (obj == Collections.EMPTY_SET || obj == Collections.EMPTY_LIST || obj == Collections.EMPTY_MAP) {
return true;
}
if (obj == BigInteger.ZERO || obj == BigInteger.ONE) {
return true;
}
if (obj == System.in || obj == System.out || obj == System.err) {
return true;
}
if (obj == String.CASE_INSENSITIVE_ORDER) {
return true;
}
if (obj == JarFile.MANIFEST_NAME) {
return true;
}
return false;
}
示例13: writeProlog
/**
*
**/
public static void writeProlog (PrintWriter stream, String filename)
{
// <d59355> Remove target directory
String targetDir = ((Arguments)Compile.compiler.arguments).targetDir;
if (targetDir != null)
filename = filename.substring (targetDir.length ());
stream.println ();
stream.println ("/**");
stream.println ("* " + filename.replace (File.separatorChar, '/') +
" .");
stream.println ("* " + Util.getMessage ("toJavaProlog1",
Util.getMessage ("Version.product", Util.getMessage ("Version.number"))));
// <d48911> Do not introduce invalid escape characters into comment! <daz>
//stream.println ("* " + Util.getMessage ("toJavaProlog2", Compile.compiler.arguments.file));
stream.println ("* " + Util.getMessage ("toJavaProlog2", Compile.compiler.arguments.file.replace (File.separatorChar, '/')));
///////////////
// This SHOULD work, but there's a bug in the JDK.
// stream.println ("* " + DateFormat.getDateTimeInstance (DateFormat.FULL, DateFormat.FULL, Locale.getDefault ()).format (new Date ()));
// This gets around the bug:
DateFormat formatter = DateFormat.getDateTimeInstance (DateFormat.FULL, DateFormat.FULL, Locale.getDefault ());
// Japanese-specific workaround. JDK bug 4069784 being repaired by JavaSoft.
// Keep this transient solution until bug fix is reported.cd .
if (Locale.getDefault () == Locale.JAPAN)
formatter.setTimeZone (java.util.TimeZone.getTimeZone ("JST"));
else
formatter.setTimeZone (java.util.TimeZone.getDefault ());
stream.println ("* " + formatter.format (new Date ()));
// <daz>
///////////////
stream.println ("*/");
stream.println ();
}
示例14: data_localeList
@DataProvider(name = "localeList")
Locale[] data_localeList() {
return new Locale[] {
Locale.US,
Locale.GERMAN,
Locale.JAPAN,
Locale.ROOT,
};
}
示例15: testFormatting
static void testFormatting() {
boolean failed = false;
Locale[] locales = {
Locale.US,
Locale.JAPAN,
Locale.GERMANY,
Locale.ITALY,
new Locale("it", "IT", "EURO") };
Currency[] currencies = {
null,
Currency.getInstance("USD"),
Currency.getInstance("JPY"),
Currency.getInstance("DEM"),
Currency.getInstance("EUR"),
};
String[][] expecteds = {
{"$1,234.56", "$1,234.56", "JPY1,235", "DEM1,234.56", "EUR1,234.56"},
{"\uFFE51,235", "USD1,234.56", "\uFFE51,235", "DEM1,234.56", "EUR1,234.56"},
{"1.234,56 \u20AC", "1.234,56 USD", "1.235 JPY", "1.234,56 DM", "1.234,56 \u20AC"},
{"\u20AC 1.234,56", "USD 1.234,56", "JPY 1.235", "DEM 1.234,56", "\u20AC 1.234,56"},
{"\u20AC 1.234,56", "USD 1.234,56", "JPY 1.235", "DEM 1.234,56", "\u20AC 1.234,56"},
};
for (int i = 0; i < locales.length; i++) {
Locale locale = locales[i];
NumberFormat format = NumberFormat.getCurrencyInstance(locale);
for (int j = 0; j < currencies.length; j++) {
Currency currency = currencies[j];
String expected = expecteds[i][j];
if (currency != null) {
format.setCurrency(currency);
int digits = currency.getDefaultFractionDigits();
format.setMinimumFractionDigits(digits);
format.setMaximumFractionDigits(digits);
}
String result = format.format(1234.56);
if (!result.equals(expected)) {
failed = true;
System.out.println("FAIL: Locale " + locale
+ (currency == null ? ", default currency" : (", currency: " + currency))
+ ", expected: " + expected
+ ", actual: " + result);
}
}
}
if (failed) {
throw new RuntimeException();
}
}