C#でよく利用されているTicks値をJavaのサービスで解析するために書いたコード
paizaへのリンクはこちら
https://paiza.io/projects/3G0Z2TzELkiqeUrvXyENeQ
import java.util.*; public class Main { /** Ticks default date 1970/1/1 0:0:0 */ private static long TICKS_AT_EPOCH = 621355968000000000L; /** Ticks変換用 */ private static long TEN_THOUSAND = 10000L; public static void main(String[] args) throws Exception { // request ticks value long ticks = 637854553115230580L; long createDateTime = (ticks - TICKS_AT_EPOCH) / TEN_THOUSAND; // set Date Entity Date createDate = new Date(createDateTime); // set Calendar Entity Calendar calendar = Calendar.getInstance(); calendar.setTime(createDate); // months int months = calendar.get(Calendar.MONTH) + 1; System.out.println(calendar.get(Calendar.YEAR) + "/" + months + "/" + calendar.get(Calendar.DAY_OF_MONTH) + " " + calendar.get(Calendar.HOUR) + ":" + calendar.get(Calendar.MINUTE) + ":" + calendar.get(Calendar.SECOND) ); } }