signal-cli/src/main/java/org/asamk/signal/util/DateUtils.java
AsamK 03c30519b1 Refactor ReceiveMessageHandler
Introduce PlainTextWriter to improve indentation handling.
2021-02-20 19:22:36 +01:00

21 lines
606 B
Java

package org.asamk.signal.util;
import java.text.DateFormat;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.TimeZone;
public class DateUtils {
private static final TimeZone tzUTC = TimeZone.getTimeZone("UTC");
private DateUtils() {
}
public static String formatTimestamp(long timestamp) {
Date date = new Date(timestamp);
final DateFormat df = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss.SSSX"); // Quoted "Z" to indicate UTC, no timezone offset
df.setTimeZone(tzUTC);
return timestamp + " (" + df.format(date) + ")";
}
}