diff options
Diffstat (limited to 'core/src/main/java/org/bouncycastle/asn1/ASN1UTCTime.java')
-rw-r--r-- | core/src/main/java/org/bouncycastle/asn1/ASN1UTCTime.java | 19 |
1 files changed, 19 insertions, 0 deletions
diff --git a/core/src/main/java/org/bouncycastle/asn1/ASN1UTCTime.java b/core/src/main/java/org/bouncycastle/asn1/ASN1UTCTime.java index 2297cfef..2c82df30 100644 --- a/core/src/main/java/org/bouncycastle/asn1/ASN1UTCTime.java +++ b/core/src/main/java/org/bouncycastle/asn1/ASN1UTCTime.java @@ -4,6 +4,7 @@ import java.io.IOException; import java.text.ParseException; import java.text.SimpleDateFormat; import java.util.Date; +import java.util.Locale; import java.util.SimpleTimeZone; import org.bouncycastle.util.Arrays; @@ -129,6 +130,24 @@ public class ASN1UTCTime this.time = Strings.toByteArray(dateF.format(time)); } + /** + * Base constructor from a java.util.date and Locale - you may need to use this if the default locale + * doesn't use a Gregorian calender so that the GeneralizedTime produced is compatible with other ASN.1 implementations. + * + * @param time a date object representing the time of interest. + * @param locale an appropriate Locale for producing an ASN.1 UTCTime value. + */ + public ASN1UTCTime( + Date time, + Locale locale) + { + SimpleDateFormat dateF = new SimpleDateFormat("yyMMddHHmmss'Z'", locale); + + dateF.setTimeZone(new SimpleTimeZone(0,"Z")); + + this.time = Strings.toByteArray(dateF.format(time)); + } + ASN1UTCTime( byte[] time) { |