|
86 | 86 | import java.security.spec.InvalidKeySpecException;
|
87 | 87 | import java.security.spec.InvalidParameterSpecException;
|
88 | 88 | import java.security.spec.PKCS8EncodedKeySpec;
|
89 |
| -import java.text.SimpleDateFormat; |
90 | 89 | import java.util.ArrayList;
|
91 | 90 | import java.util.Base64;
|
92 |
| -import java.util.Calendar; |
93 | 91 | import java.util.Collection;
|
94 | 92 | import java.util.Collections;
|
95 | 93 | import java.util.Date;
|
96 | 94 | import java.util.List;
|
97 |
| -import java.util.TimeZone; |
98 | 95 | import java.util.logging.Level;
|
99 | 96 |
|
100 | 97 | import javax.crypto.interfaces.DHPrivateKey;
|
|
110 | 107 | import com.oracle.truffle.api.CompilerDirectives.TruffleBoundary;
|
111 | 108 | import com.oracle.truffle.api.TruffleFile;
|
112 | 109 | import com.oracle.truffle.api.nodes.Node;
|
| 110 | +import java.time.ZoneId; |
| 111 | +import java.time.ZonedDateTime; |
| 112 | +import java.time.format.DateTimeFormatter; |
113 | 113 |
|
114 | 114 | import sun.security.provider.certpath.OCSP;
|
115 | 115 | import sun.security.util.DerValue;
|
@@ -210,23 +210,12 @@ private static String getNotBefore(X509Certificate x509Certificate) {
|
210 | 210 | return formatDate(x509Certificate.getNotBefore());
|
211 | 211 | }
|
212 | 212 |
|
213 |
| - private static final SimpleDateFormat DF1 = new SimpleDateFormat("MMM d HH:mm:ss yyyy z"); |
214 |
| - private static final SimpleDateFormat DF2 = new SimpleDateFormat("MMM dd HH:mm:ss yyyy z"); |
215 |
| - private static final Calendar CAL = Calendar.getInstance(TimeZone.getTimeZone("GMT")); |
216 |
| - static { |
217 |
| - DF1.setTimeZone(TimeZone.getTimeZone("GMT")); |
218 |
| - DF2.setTimeZone(TimeZone.getTimeZone("GMT")); |
219 |
| - } |
| 213 | + private static final ZoneId zoneId = ZoneId.of("GMT"); |
| 214 | + private static final DateTimeFormatter DF = DateTimeFormatter.ofPattern("MMM ppd HH:mm:ss yyyy z"); |
220 | 215 |
|
221 | 216 | @TruffleBoundary
|
222 | 217 | private static String formatDate(Date d) {
|
223 |
| - CAL.setTime(d); |
224 |
| - int day = CAL.get(Calendar.DAY_OF_MONTH); |
225 |
| - if (day < 10) { |
226 |
| - return DF1.format(d); |
227 |
| - } else { |
228 |
| - return DF2.format(d); |
229 |
| - } |
| 218 | + return ZonedDateTime.ofInstant(d.toInstant(), zoneId).format(DF); |
230 | 219 | }
|
231 | 220 |
|
232 | 221 | @TruffleBoundary
|
|
0 commit comments