io.castle.client.internal.utils.Timestamp Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of castle-java Show documentation
Show all versions of castle-java Show documentation
Castle adds real-time monitoring of your authentication stack, instantly notifying you and your users
on potential account hijacks.
package io.castle.client.internal.utils;
import java.text.DateFormat;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.Locale;
import java.util.TimeZone;
public class Timestamp {
private static final DateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss.SSS'Z'", new Locale("en", "US", "POSIX"));
/**
* Return an ISO 8601 combined date and time string for current date/time
*
* @return String with format "yyyy-MM-dd'T'HH:mm:ss.SSS'Z'"
*/
public static String timestamp() {
return timestamp(new Date());
}
/**
* Return an ISO 8601 combined date and time string for specified date/time
*
* @param date Date
* @return String with format "yyyy-MM-dd'T'HH:mm:ss.SSS'Z'"
*/
public static String timestamp(Date date) {
dateFormat.setTimeZone(TimeZone.getTimeZone("UTC"));
return dateFormat.format(date);
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy