| | |
| | | import java.lang.reflect.InvocationTargetException; |
| | | import java.nio.ByteBuffer; |
| | | import java.text.ParseException; |
| | | import java.text.SimpleDateFormat; |
| | | import java.util.ArrayList; |
| | | import java.util.LinkedHashMap; |
| | | import java.util.LinkedHashSet; |
| | |
| | | import java.util.Map; |
| | | import java.util.RandomAccess; |
| | | import java.util.StringTokenizer; |
| | | import java.util.Date; |
| | | import java.util.TimeZone; |
| | | |
| | | import org.opends.messages.Message; |
| | | import org.opends.messages.MessageBuilder; |
| | |
| | | import org.opends.server.types.RDN; |
| | | |
| | | |
| | | |
| | | /** |
| | | * This class defines a number of static utility methods that may be used |
| | | * throughout the server. Note that because of the frequency with which these |
| | |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * Converts a string representing a time in "yyyyMMddHHmmss.SSS'Z'" or |
| | | * "yyyyMMddHHmmss" to a <code>Date</code>. |
| | | * |
| | | * @param timeStr string formatted appropriately |
| | | * @return Date object; null if <code>timeStr</code> is null |
| | | * @throws ParseException if there was a problem converting the string to |
| | | * a <code>Date</code>. |
| | | */ |
| | | static public Date parseDateTimeString(String timeStr) throws ParseException |
| | | { |
| | | Date dateTime = null; |
| | | if (timeStr != null) |
| | | { |
| | | if (timeStr.endsWith("Z")) |
| | | { |
| | | SimpleDateFormat dateFormat = |
| | | new SimpleDateFormat(DATE_FORMAT_GENERALIZED_TIME); |
| | | dateFormat.setTimeZone(TimeZone.getTimeZone("UTC")); |
| | | dateFormat.setLenient(true); |
| | | dateTime = dateFormat.parse(timeStr); |
| | | } |
| | | else |
| | | { |
| | | SimpleDateFormat dateFormat = |
| | | new SimpleDateFormat(DATE_FORMAT_COMPACT_LOCAL_TIME); |
| | | dateFormat.setLenient(true); |
| | | dateTime = dateFormat.parse(timeStr); |
| | | } |
| | | } |
| | | return dateTime; |
| | | } |
| | | |
| | | /** |
| | | * Formats a Date to String representation in "yyyyMMddHHmmss'Z'". |
| | | * |
| | | * @param date to format; null if <code>date</code> is null |
| | | * @return string representation of the date |
| | | */ |
| | | static public String formatDateTimeString(Date date) |
| | | { |
| | | String timeStr = null; |
| | | if (date != null) |
| | | { |
| | | SimpleDateFormat dateFormat = new SimpleDateFormat(DATE_FORMAT_GMT_TIME); |
| | | dateFormat.setTimeZone(TimeZone.getTimeZone("UTC")); |
| | | timeStr = dateFormat.format(date); |
| | | } |
| | | return timeStr; |
| | | } |
| | | |
| | | } |
| | | |