diff options
Diffstat (limited to 'pki/base/common/src/com/netscape/cms/servlet/cert/Monitor.java')
-rw-r--r-- | pki/base/common/src/com/netscape/cms/servlet/cert/Monitor.java | 24 |
1 files changed, 15 insertions, 9 deletions
diff --git a/pki/base/common/src/com/netscape/cms/servlet/cert/Monitor.java b/pki/base/common/src/com/netscape/cms/servlet/cert/Monitor.java index 649d70169..db77d039c 100644 --- a/pki/base/common/src/com/netscape/cms/servlet/cert/Monitor.java +++ b/pki/base/common/src/com/netscape/cms/servlet/cert/Monitor.java @@ -19,6 +19,7 @@ package com.netscape.cms.servlet.cert; import java.io.IOException; +import java.util.Calendar; import java.util.Date; import java.util.Enumeration; import java.util.Locale; @@ -341,14 +342,15 @@ public class Monitor extends CMSServlet { z.length() == 15 && (z.charAt(14) == 'Z' || z.charAt(14) == 'z'))) { // 20020516132030Z or 20020516132030 try { - int year = Integer.parseInt(z.substring(0, 4)) - 1900; + int year = Integer.parseInt(z.substring(0, 4)); int month = Integer.parseInt(z.substring(4, 6)) - 1; int date = Integer.parseInt(z.substring(6, 8)); int hour = Integer.parseInt(z.substring(8, 10)); int minute = Integer.parseInt(z.substring(10, 12)); int second = Integer.parseInt(z.substring(12, 14)); - - d = new Date(year, month, date, hour, minute, second); + Calendar calendar= Calendar.getInstance(); + calendar.set(year, month, date, hour, minute, second); + d = calendar.getTime(); } catch (NumberFormatException nfe) { } } else if (z != null && z.length() > 1 && z.charAt(0) == '-') { // -5 @@ -365,21 +367,25 @@ public class Monitor extends CMSServlet { } String DateToZString(Date d) { - String time = "" + (d.getYear() + 1900); - int i = d.getMonth() + 1; + Calendar calendar = Calendar.getInstance(); + calendar.setTime(d); + + + String time = "" + (calendar.get(Calendar.YEAR)); + int i = calendar.get(Calendar.MONTH) + 1; if (i < 10) time += "0"; time += i; - i = d.getDate(); + i = calendar.get(Calendar.DAY_OF_MONTH); if (i < 10) time += "0"; time += i; - i = d.getHours(); + i = calendar.get(Calendar.HOUR_OF_DAY); if (i < 10) time += "0"; time += i; - i = d.getMinutes(); + i = calendar.get(Calendar.MINUTE); if (i < 10) time += "0"; time += i; - i = d.getSeconds(); + i = calendar.get(Calendar.SECOND); if (i < 10) time += "0"; time += i + "Z"; return time; |