mirror of
https://github.com/AsamK/signal-cli
synced 2025-08-30 02:50:39 +00:00
Extract util methods to separate classes
This commit is contained in:
parent
4ab904b88e
commit
7443225d96
6 changed files with 168 additions and 131 deletions
21
src/main/java/org/asamk/signal/util/DateUtils.java
Normal file
21
src/main/java/org/asamk/signal/util/DateUtils.java
Normal file
|
@ -0,0 +1,21 @@
|
|||
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.SSS'Z'"); // Quoted "Z" to indicate UTC, no timezone offset
|
||||
df.setTimeZone(tzUTC);
|
||||
return timestamp + " (" + df.format(date) + ")";
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue