mirror of
https://github.com/openjdk/jdk.git
synced 2026-03-04 21:20:17 +00:00
8150324: java/util/Currency/CurrencyTest.java does not restore default TimeZone
Reviewed-by: okutsu, peytoia
This commit is contained in:
parent
4544652494
commit
91f88bbdca
@ -23,7 +23,7 @@
|
||||
/*
|
||||
* @test
|
||||
* @bug 4290801 4692419 4693631 5101540 5104960 6296410 6336600 6371531
|
||||
* 6488442 7036905 8008577 8039317 8074350 8074351
|
||||
* 6488442 7036905 8008577 8039317 8074350 8074351 8150324
|
||||
* @summary Basic tests for Currency class.
|
||||
* @modules jdk.localedata
|
||||
*/
|
||||
@ -32,12 +32,12 @@ import java.io.ByteArrayInputStream;
|
||||
import java.io.ByteArrayOutputStream;
|
||||
import java.io.ObjectInputStream;
|
||||
import java.io.ObjectOutputStream;
|
||||
import java.util.Calendar;
|
||||
import java.util.Date;
|
||||
import java.time.LocalDate;
|
||||
import java.time.LocalTime;
|
||||
import java.time.ZoneId;
|
||||
import java.time.ZonedDateTime;
|
||||
import java.util.Currency;
|
||||
import java.util.GregorianCalendar;
|
||||
import java.util.Locale;
|
||||
import java.util.TimeZone;
|
||||
|
||||
|
||||
public class CurrencyTest {
|
||||
@ -137,7 +137,7 @@ public class CurrencyTest {
|
||||
|
||||
/*
|
||||
* check currency changes
|
||||
* In current implementation, there is no data of old currency and transition date at jdk/src/share/classes/java/util/CurrencyData.properties.
|
||||
* In current implementation, there is no data of old currency and transition date at jdk/make/data/currency/CurrencyData.properties.
|
||||
* So, all the switch data arrays are empty. In the future, if data of old currency and transition date are necessary for any country, the
|
||||
* arrays here can be updated so that the program can check the currency switch.
|
||||
*/
|
||||
@ -146,15 +146,16 @@ public class CurrencyTest {
|
||||
String[] switchOverNew = {};
|
||||
String[] switchOverTZ = {};
|
||||
int[] switchOverYear = {};
|
||||
int[] switchOverMonth = {};
|
||||
int[] switchOverMonth = {}; // java.time APIs accept month starting from 1 i.e. 01 for January
|
||||
int[] switchOverDay = {};
|
||||
|
||||
for (int i = 0; i < switchOverCtry.length; i++) {
|
||||
TimeZone.setDefault(TimeZone.getTimeZone(switchOverTZ[i]));
|
||||
Calendar date = new GregorianCalendar(switchOverYear[i], switchOverMonth[i], switchOverDay[i]);
|
||||
long switchOver = date.getTime().getTime();
|
||||
boolean switchedOver = System.currentTimeMillis() >= switchOver;
|
||||
checkCountryCurrency(switchOverCtry[i], switchedOver ? switchOverNew[i] : switchOverOld[i]);
|
||||
ZoneId zoneId = ZoneId.of(switchOverTZ[i]);
|
||||
ZonedDateTime zonedDateAndTime = ZonedDateTime.of(LocalDate.of(switchOverYear[i], switchOverMonth[i], switchOverDay[i]),
|
||||
LocalTime.MIDNIGHT, zoneId);
|
||||
ZonedDateTime currentZonedDateAndTime = ZonedDateTime.now(zoneId);
|
||||
checkCountryCurrency(switchOverCtry[i], (currentZonedDateAndTime.isAfter(zonedDateAndTime) ||
|
||||
currentZonedDateAndTime.isEqual(zonedDateAndTime)) ? switchOverNew[i] : switchOverOld[i]);
|
||||
}
|
||||
|
||||
// check a country code which doesn't have a currency
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user