1 7 8 package org.enhydra.oyster.der; 9 10 import org.enhydra.oyster.exception.SMIMEException; 11 import org.enhydra.oyster.exception.ErrorStorage; 12 import java.util.GregorianCalendar ; 13 import java.util.Date ; 14 import java.util.TimeZone ; 15 import java.text.SimpleDateFormat ; 16 17 23 public class DERUTCTime extends DERObject { 24 25 31 public DERUTCTime () throws SMIMEException 32 { 33 super(23); 34 TimeZone tz = TimeZone.getDefault(); 35 tz.setRawOffset(0); GregorianCalendar cal = new GregorianCalendar (tz); 37 SimpleDateFormat datForm = new SimpleDateFormat ("yyMMddHHmmss'Z'"); datForm.setCalendar(cal); 39 byte[] utcTime = null; 40 try { 41 utcTime = datForm.format(cal.getTime()).getBytes("ISO-8859-1"); 42 } 43 catch(Exception e) { 44 throw SMIMEException.getInstance(this, e, "constructor" ); 45 } 46 this.addContent(utcTime); 47 } 48 49 55 public DERUTCTime (Date dat0) throws SMIMEException 56 { 57 super(23); 58 TimeZone tz = TimeZone.getDefault(); 59 tz.setRawOffset(0); GregorianCalendar cal = new GregorianCalendar (tz); 61 cal.setTime(dat0); 62 SimpleDateFormat datForm = new SimpleDateFormat ("yyMMddHHmmss'Z'"); datForm.setCalendar(cal); 64 byte[] utcTime = null; 65 try { 66 utcTime = datForm.format(cal.getTime()).getBytes("ISO-8859-1"); 67 } 68 catch(Exception e) { 69 throw SMIMEException.getInstance(this, e, "constructor" ); 70 } 71 this.addContent(utcTime); 72 } 73 74 81 public DERUTCTime (GregorianCalendar cal0) throws SMIMEException 82 { 83 super(23); 84 TimeZone tz = TimeZone.getDefault(); 85 tz.setRawOffset(0); cal0.setTimeZone(tz); 87 SimpleDateFormat datForm = new SimpleDateFormat ("yyMMddHHmmss'Z'"); datForm.setCalendar(cal0); 89 byte[] utcTime = null; 90 try { 91 utcTime = datForm.format(cal0.getTime()).getBytes("ISO-8859-1"); 92 } 93 catch(Exception e) { 94 throw SMIMEException.getInstance(this, e, "constructor" ); 95 } 96 this.addContent(utcTime); 97 } 98 99 105 public DERUTCTime (byte[] utcTime0) throws SMIMEException 106 { 107 super(23); 108 this.addContent(utcTime0); 109 } 110 111 118 public DERUTCTime (String utcTime0) throws SMIMEException 119 { 120 super(23); 121 try { 122 this.addContent(utcTime0.getBytes("ISO-8859-1")); 123 } 124 catch(Exception e) { 125 throw SMIMEException.getInstance(this, e, "constructor" ); 126 } 127 } 128 } 129 130 131 132 | Popular Tags |