public Date decodeTime(boolean implicit) throws Asn1Exception {

        //
        // There must be at least 2 bytes available
        //
        if (residualLength < 2)
            throw new Asn1Exception("Attempt to read past end of stream");

        //
        // Validate the tag for an explicit value
        //
        if (!implicit && stream[next] != ASN1_GENERALTIME)
            throw new Asn1Exception("Field at offset "+next+" is not a GENERALTIME");

        if ((stream[next]&ASN1_CONSTRUCTED) != 0)
            throw new Asn1Exception("GENERALTIME must not be a constructed field");

        next++;
        residualLength--;

        //
        // Decode the field length
        //
        int length = decodeLength();

        if (length > residualLength)
            throw new Asn1Exception("Attempt to read past end of stream");

        if (length != 15)
            throw new Asn1Exception("GENERALTIME length "+length+" is invalid");

        if (((int)stream[next+14]&0xff) != 0x5a)
            throw new Asn1Exception("GENERALTIME timezone is not GMT");

        //
        // Decode the time fields.  We just look at the lower nibble of each
        // byte since the ISO-8859-1 character set assigns the digits 0-9 to
        // code points 0x30-0x39.
        //
        int year = ((int)stream[next]&15)*1000+
                            ((int)stream[next+1]&15)*100+
                            ((int)stream[next+2]&15)*10+
                            ((int)stream[next+3]&15);
        int month = ((int)stream[next+4]&15)*10+
                            ((int)stream[next+5]&15)-1;
        int day = ((int)stream[next+6]&15)*10+
                            ((int)stream[next+7]&15);
        int hour = ((int)stream[next+8]&15)*10+
                            ((int)stream[next+9]&15);
        int minute = ((int)stream[next+10]&15)*10+
                            ((int)stream[next+11]&15);
        int second = ((int)stream[next+12]&15)*10+
                            ((int)stream[next+13]&15);
        next += 15;
        residualLength -= 15;

        //
        // Set the time
        //
        calendar.set(year, month, day, hour, minute, second);
        calendar.set(Calendar.MILLISECOND, 0);
        return calendar.getTime();
    }