From: <asa...@us...> - 2017-05-31 11:07:56
|
Revision: 14511 http://sourceforge.net/p/htmlunit/code/14511 Author: asashour Date: 2017-05-31 11:07:54 +0000 (Wed, 31 May 2017) Log Message: ----------- Use TimeZone for BrowserVersion.set/getSystemTimezone() Modified Paths: -------------- trunk/htmlunit/src/changes/changes.xml trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/BrowserVersion.java trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/javascript/host/file/File.java trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/util/UrlUtils.java Modified: trunk/htmlunit/src/changes/changes.xml =================================================================== --- trunk/htmlunit/src/changes/changes.xml 2017-05-31 10:46:40 UTC (rev 14510) +++ trunk/htmlunit/src/changes/changes.xml 2017-05-31 11:07:54 UTC (rev 14511) @@ -9,7 +9,7 @@ <body> <release version="2.27" date="???" description="GAE broken, FF52, Bugfixes"> <action type="fix" dev="rbri" issue="1827"> - Simulated system time zone is now configurable (BrowserVersion.setSystemTimezone(String)). + Simulated system time zone is now configurable (BrowserVersion.setSystemTimezone()). </action> <action type="fix" dev="asashour" issue="1886"> JavaScript: fix Set/Map with undefined value. Modified: trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/BrowserVersion.java =================================================================== --- trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/BrowserVersion.java 2017-05-31 10:46:40 UTC (rev 14510) +++ trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/BrowserVersion.java 2017-05-31 11:07:54 UTC (rev 14511) @@ -24,6 +24,7 @@ import java.util.Locale; import java.util.Map; import java.util.Set; +import java.util.TimeZone; import org.apache.commons.io.FilenameUtils; import org.apache.commons.lang3.builder.EqualsBuilder; @@ -107,7 +108,7 @@ private static final String LANGUAGE_ENGLISH_US = "en-US"; /** - * United States . + * United States. */ private static final String TIMEZONE_NEW_YORK = "America/New_York"; @@ -354,7 +355,7 @@ private boolean onLine_ = true; private String platform_ = PLATFORM_WIN32; private String systemLanguage_ = LANGUAGE_ENGLISH_US; - private String systemTimezone_ = TIMEZONE_NEW_YORK; + private TimeZone systemTimezone_ = TimeZone.getTimeZone(TIMEZONE_NEW_YORK); private String userAgent_; private String userLanguage_ = LANGUAGE_ENGLISH_US; private int browserVersionNumeric_; @@ -620,11 +621,11 @@ } /** - * Returns the system timezone, for example "America/New_York". - * Default value is {@link #TIMEZONE_NEW_YORK} if not explicitly configured. - * @return the system timezone + * Returns the system {@link TimeZone}. + * Default value is {@code America/New_York} if not explicitly configured. + * @return the system {@link TimeZone} */ - public String getSystemTimezone() { + public TimeZone getSystemTimezone() { return systemTimezone_; } @@ -763,7 +764,7 @@ /** * @param systemTimezone the systemTimezone to set */ - public void setSystemTimezone(final String systemTimezone) { + public void setSystemTimezone(final TimeZone systemTimezone) { systemTimezone_ = systemTimezone; } Modified: trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/javascript/host/file/File.java =================================================================== --- trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/javascript/host/file/File.java 2017-05-31 10:46:40 UTC (rev 14510) +++ trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/javascript/host/file/File.java 2017-05-31 11:07:54 UTC (rev 14511) @@ -74,7 +74,7 @@ final Date date = new Date(getLastModified()); final BrowserVersion browser = getBrowserVersion(); final Locale locale = new Locale(browser.getSystemLanguage()); - final TimeZone timezone = TimeZone.getTimeZone(browser.getSystemTimezone()); + final TimeZone timezone = browser.getSystemTimezone(); if (browser.hasFeature(JS_FILE_SHORT_DATE_FORMAT)) { final FastDateFormat format = FastDateFormat.getInstance(LAST_MODIFIED_DATE_FORMAT_FF, timezone, locale); Modified: trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/util/UrlUtils.java =================================================================== --- trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/util/UrlUtils.java 2017-05-31 10:46:40 UTC (rev 14510) +++ trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/util/UrlUtils.java 2017-05-31 11:07:54 UTC (rev 14511) @@ -337,7 +337,7 @@ } else { final int st = i - state + offset; - result .replace(st, st + 1, "%25"); + result.replace(st, st + 1, "%25"); offset = offset + 2; state = 0; } @@ -345,7 +345,7 @@ } if (state == 1 || state == 2) { final int st = input.length - state + offset; - result .replace(st, st + 1, "%25"); + result.replace(st, st + 1, "%25"); } return result.toString(); } |