public static void main (String as []) {
String windowNTTimeStr = "131007981071882420"; String finalDate = ""; try { //Windows NT time is specified as the number of 100 nanosecond intervals since January 1, 1601. //UNIX time is specified as the number of seconds since January 1, 1970. There are 134,774 days (or 11,644,473,600 seconds) between these dates. //NT to Unix : Divide by 10,000,000 and subtract 11,644,473,600. //Unix to NT : Add 11,644,473,600 and multiply by 10,000,000 SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); Long windowsTime = Long.parseLong(windowNTTimeStr); long javaTime = windowsTime / 10000 - 11644473600000L; Date date = new Date(javaTime); Calendar c = Calendar.getInstance(); c.setTime(new Date(javaTime)); Calendar cCurrent = Calendar.getInstance(); cCurrent.setTime(new Date()); cCurrent.add(Calendar.YEAR, 100); if (!(c.getTime().getYear() > cCurrent.getTime().getYear())) { finalDate = sdf.format(c.getTime()); } } catch (Exception e) { finalDate = null; } System.out.println(" Final Date is "+finalDate); } //Expected out put Final Date is 2016-02-24 20:05:07
user989383
source share