Currently I have tried this code, but the problem is the first line of code gives this output 20150217172651+0100 and my required output is 20150217172651.0Z
GeneralizedTime gt = new GeneralizedTime(Calendar.getInstance());
String gtADString = gt.toGeneralizedTime(
GeneralizedTime.Format.YEAR_MONTH_DAY_HOUR_MIN_SEC,
GeneralizedTime.FractionDelimiter.DOT, 1,
GeneralizedTime.TimeZoneFormat.Z).replaceFirst("Z", "\\.0Z");
Ran your code
public class poc {
public static void main(String[] args) {
GeneralizedTime gt = new GeneralizedTime(Calendar.getInstance());
String gtADString = gt.toGeneralizedTime(
GeneralizedTime.Format.YEAR_MONTH_DAY_HOUR_MIN_SEC,
GeneralizedTime.FractionDelimiter.DOT, 1,
GeneralizedTime.TimeZoneFormat.Z).replaceFirst("Z", "\\.0Z");
System.out.println(gtADString);
}
}
And got this as output:
20150217163832.0Z
Using the following dependency:
<dependency>
<groupId>org.apache.directory.api</groupId>
<artifactId>api-util</artifactId>
<version>1.0.0-M28</version>
</dependency>`
You can try as follow:
long t1 = calenderObj.getTimeInMillis();
calenderObj.set(1601, 0, 1);
long t2 = calenderObj.getTimeInMillis();
long ldap = (t1 - t2) * 10000;
Hope this would help.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.