Skip to content

Instantly share code, notes, and snippets.

@vitran96
Last active June 10, 2020 07:51
Show Gist options
  • Save vitran96/0bdc974d9edddc1e0651b53353bc6906 to your computer and use it in GitHub Desktop.
Save vitran96/0bdc974d9edddc1e0651b53353bc6906 to your computer and use it in GitHub Desktop.
import java.text.SimpleDateFormat;
import java.util.Date;
public class JavaTimestampTest {
public static void main(String []args){
// long timestamp = new Date().getTime();
long timestamp = 1_591_768_420_177L - 8_610_000_000L;
Date date = new Date(timestamp);
// F - increase by every 7 days of the month
// W - increase by sunday of the month
// String format = "yyyy-MM-dd'T'HH:mm:ss'.'SSSZ yyMM";
String format = "w W F E dd-MM-yyyy'T'HH:mm:ss'.'SSSZ";
SimpleDateFormat formatter = new SimpleDateFormat(format);
String result = formatter.format(date);
System.out.println("Timestamp: " + timestamp);
System.out.println("Format: " + format);
System.out.println("Result: " + result);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment