FileDocCategorySizeDatePackage
ASN1GeneralizedTime.javaAPI DocAndroid 1.5 API3698Wed May 06 22:41:06 BST 2009org.apache.harmony.security.asn1

ASN1GeneralizedTime

public class ASN1GeneralizedTime extends ASN1Time
This class represents ASN.1 GeneralizedTime type. According to X.680 specification this type is defined as follows: GeneralizedTime ::= [UNIVERSAL 24] IMPLICIT VisibleString
see
ASN.1

Fields Summary
private static final ASN1GeneralizedTime
ASN1
private static final String
GEN_PATTERN
Constructors Summary
public ASN1GeneralizedTime()
Constructs ASN.1 GeneralizedTime type The constructor is provided for inheritance purposes when there is a need to create a custom ASN.1 GeneralizedTime type. To get a default implementation it is recommended to use getInstance() method.


                                             
      
        super(TAG_GENERALIZEDTIME);
    
Methods Summary
public java.lang.Objectdecode(BerInputStream in)

        in.readGeneralizedTime();

        if (in.isVerify) {
            return null;
        }
        return getDecodedObject(in);
    
public voidencodeContent(BerOutputStream out)

        out.encodeGeneralizedTime();
    
public static org.apache.harmony.security.asn1.ASN1GeneralizedTimegetInstance()
Returns ASN.1 GeneralizedTime type default implementation The default implementation works with encoding that is represented as Date object.

return
ASN.1 GeneralizedTime type default implementation

        return ASN1;
    
public voidsetEncodingContent(BerOutputStream out)

 //$NON-NLS-1$

        

        SimpleDateFormat sdf = new SimpleDateFormat(GEN_PATTERN);
        sdf.setTimeZone(TimeZone.getTimeZone("UTC")); //$NON-NLS-1$
        String temp = sdf.format(out.content);
        // cut off trailing 0s
        int nullId;
        int currLength;
        while (((nullId = temp.lastIndexOf('0", currLength = temp.length() - 1)) != -1)
                & (nullId == currLength)) {
            temp = temp.substring(0, nullId);
        }
        // deal with point (cut off if it is last char)
        if (temp.charAt(currLength) == '.") {
            temp = temp.substring(0, currLength);
        }
        out.content = (temp + "Z").getBytes(); //$NON-NLS-1$
        out.length = ((byte[]) out.content).length;