} SimpleDateFormat sdf = new SimpleDateFormat(pattern, Locale.US); sdf.setTimeZone(tz); byte[] time = (sdf.format(d)).getBytes("ISO-8859-1"); /* * Write the formatted date. */ write(tag); putLength(time.length); write(time); } /** * Put the encoding of the length in the stream. * * @params len the length of the attribute. * @exception IOException on writing errors. */ public void putLength(int len) throws IOException { if (len < 128) { write((byte)len); } else if (len < (1 << 8)) { write((byte)0x081); write((byte)len); } else if (len < (1 << 16)) { write((byte)0x082); write((byte)(len >> 8)); write((byte)len); } else if (len < (1 << 24)) { write((byte)0x083); write((byte)(len >> 16)); write((byte)(len >> 8)); write((byte)len); } else { write((byte)0x084); write((byte)(len >> 24)); write((byte)(len >> 16)); write((byte)(len >> 8)); write((byte)len); } } /** * Put the tag of the attribute in the stream. * * @params class the tag class type, one of UNIVERSAL, CONTEXT, * APPLICATION or PRIVATE * @params form if true, the value is constructed, otherwise it is * primitive. * @params val the tag value */ public void putTag(byte tagClass, boolean form, byte val) { byte tag = (byte)(tagClass | val); if (form) { tag |= (byte)0x20; } write(tag); } /** * Write the current contents of this <code>DerOutputStream</code> * to an <code>OutputStream</code>. * * @exception IOException on output error. */ public void derEncode(OutputStream out) throws IOException { out.write(toByteArray()); }}Lines 501–576 of 576. Previous lines
} SimpleDateFormat sdf = new SimpleDateFormat(pattern, Locale.US); sdf.setTimeZone(tz); byte[] time = (sdf.format(d)).getBytes("ISO-8859-1"); /* * Write the formatted date. */ write(tag); putLength(time.length); write(time); } /** * Put the encoding of the length in the stream. * * @params len the length of the attribute. * @exception IOException on writing errors. */ public void putLength(int len) throws IOException { if (len < 128) { write((byte)len); } else if (len < (1 << 8)) { write((byte)0x081); write((byte)len); } else if (len < (1 << 16)) { write((byte)0x082); write((byte)(len >> 8)); write((byte)len); } else if (len < (1 << 24)) { write((byte)0x083); write((byte)(len >> 16)); write((byte)(len >> 8)); write((byte)len); } else { write((byte)0x084); write((byte)(len >> 24)); write((byte)(len >> 16)); write((byte)(len >> 8)); write((byte)len); } } /** * Put the tag of the attribute in the stream. * * @params class the tag class type, one of UNIVERSAL, CONTEXT, * APPLICATION or PRIVATE * @params form if true, the value is constructed, otherwise it is * primitive. * @params val the tag value */ public void putTag(byte tagClass, boolean form, byte val) { byte tag = (byte)(tagClass | val); if (form) { tag |= (byte)0x20; } write(tag); } /** * Write the current contents of this <code>DerOutputStream</code> * to an <code>OutputStream</code>. * * @exception IOException on output error. */ public void derEncode(OutputStream out) throws IOException { out.write(toByteArray()); } }