protected void toValue() throws IOException { String dateStr = new String(getBytes(), StandardCharsets.US_ASCII); String fixedDateStr = dateStr; /* * Make sure fixed date str be of the complete pattern 'YYMMDDhhmmss+/-hhmm' */ int strLen = fixedDateStr.length(); if (strLen == 6) { // YYMMDD fixedDateStr += "000000+0000"; } else if (strLen == 7) { // YYMMDDZ fixedDateStr = fixedDateStr.replace("Z", "000000+0000"); } else if (strLen == 10) { // YYMMDDhhmm fixedDateStr += "00+0000"; } else if (strLen == 11) { // YYMMDDhhmmZ fixedDateStr = fixedDateStr.replace("Z", "00+0000"); } else if (strLen == 12) { // YYMMDDhhmmss fixedDateStr += "+0000"; } else if (strLen == 13) { // YYMMDDhhmmZ fixedDateStr = fixedDateStr.replace("Z", "+0000"); } else if (strLen != 17) { throw new IllegalArgumentException("Bad utc time string " + dateStr); } SimpleDateFormat sdf = new SimpleDateFormat("yyMMddHHmmssZ"); sdf.setTimeZone(new SimpleTimeZone(0, "Z")); try { setValue(sdf.parse(fixedDateStr)); } catch (ParseException e) { throw new IOException("Failed to parse " + dateStr + " as utc time", e); } }
public Date getUtcTime() { return getChoiceValueAs(TimeField.UTC_TIME, Asn1UtcTime.class).getValue(); }
return new Asn1UniversalString(); case UTC_TIME: return new Asn1UtcTime(); case UTF8_STRING: return new Asn1Utf8String();
public Date getUtcTime() { return getChoiceValueAs(TimeField.UTC_TIME, Asn1UtcTime.class).getValue(); }
return new Asn1UniversalString(); case UTC_TIME: return new Asn1UtcTime(); case UTF8_STRING: return new Asn1Utf8String();
protected void toValue() throws IOException { String dateStr = new String(getBytes(), StandardCharsets.US_ASCII); String fixedDateStr = dateStr; /* * Make sure fixed date str be of the complete pattern 'YYMMDDhhmmss+/-hhmm' */ int strLen = fixedDateStr.length(); if (strLen == 6) { // YYMMDD fixedDateStr += "000000+0000"; } else if (strLen == 7) { // YYMMDDZ fixedDateStr = fixedDateStr.replace("Z", "000000+0000"); } else if (strLen == 10) { // YYMMDDhhmm fixedDateStr += "00+0000"; } else if (strLen == 11) { // YYMMDDhhmmZ fixedDateStr = fixedDateStr.replace("Z", "00+0000"); } else if (strLen == 12) { // YYMMDDhhmmss fixedDateStr += "+0000"; } else if (strLen == 13) { // YYMMDDhhmmZ fixedDateStr = fixedDateStr.replace("Z", "+0000"); } else if (strLen != 17) { throw new IllegalArgumentException("Bad utc time string " + dateStr); } SimpleDateFormat sdf = new SimpleDateFormat("yyMMddHHmmssZ"); sdf.setTimeZone(new SimpleTimeZone(0, "Z")); try { setValue(sdf.parse(fixedDateStr)); } catch (ParseException e) { throw new IOException("Failed to parse " + dateStr + " as utc time", e); } }