Bug #176
add function getAccountExpires to AD.class
| Status: | Closed | Start: | 12/02/2010 | |
|---|---|---|---|---|
| Priority: | Normal | Due date: | ||
| Assigned to: | Rémy-Christophe Schermesser | % Done: | 100% |
|
| Category: | Core | |||
| Target version: | 1.2.0 | |||
| Problem in version: |
Description
Allow lsc to insert an expire date time in Active Directory using simple String date format like yyyy-MM-dd
/**
* Return the accountexpires time in microsoft format
*
* @param expireDate the date in yyyy-MM-dd format
* @return the date in microsoft AD format
* @throws ParseException
*/
public static long getAccountExpires(String expireDate) throws ParseException {
if (expireDate null || expireDate.length() 0) {
return 0;
}
long laccountExpiresAdjust = 116444736000000000L; // adjust factor for converting it to java
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
long accountExpiresTimeStamp = sdf.parse(expireDate).getTime();
long accountExpiresTimeStampMs = accountExpiresTimeStamp * (long) Math.pow(10, 4);
return (long) (accountExpiresTimeStampMs + laccountExpiresAdjust);
}
Associated revisions
Add a fonction to transform the date in Microsoft AD expires date weird format
This patch was contributed by Frederic Soulier
Fixes #176
Add a fonction to transform the date in Microsoft AD expires date weird format
This patch was contributed by Frederic Soulier
Fixes #176
History
Updated by Frederic Soulier 6 months ago
better formatting :
/**
* Return the accountexpires time in microsoft format
*
* @param expireDate the date in yyyy-MM-dd format
* @return the date in microsoft AD format
* @throws ParseException
*/
public static long getAccountExpires(String expireDate) throws ParseException {
if (expireDate == null || expireDate.length() == 0) {
return 0;
}
long laccountExpiresAdjust = 116444736000000000L; // adjust factor for converting it to java
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
long accountExpiresTimeStamp = sdf.parse(expireDate).getTime();
long accountExpiresTimeStampMs = accountExpiresTimeStamp * (long) Math.pow(10, 4);
return (long) (accountExpiresTimeStampMs + laccountExpiresAdjust);
}
Updated by Frederic Soulier 6 months ago
require the following includes :
import java.text.SimpleDateFormat; import java.text.ParseException;
Updated by Rémy-Christophe Schermesser 6 months ago
- Assigned to set to Rémy-Christophe Schermesser
Thanks for the fonction.
I will add this to the core right away.
I think I will add a function that takes a date and a format so everyone could have his way to specify a date
Updated by Rémy-Christophe Schermesser 6 months ago
- Status changed from New to Feedback
- % Done changed from 0 to 100
It's in the 1.2 and in the trunk.
Thanks for the patch :)
Updated by Jonathan Clarke 5 months ago
- Status changed from Feedback to Closed
Closing this issue as the patch has been applied, and no negative feedback received.
Please file a new issue if you encounter a problem with this feature. Thanks for the contribution!