HimeraNfsUtils { public static nfstime3 convertTimestamp(long gmtMillis) { nfstime3 result = new nfstime3(); result.seconds = new uint32( (int)TimeUnit.SECONDS.convert(gmtMillis , TimeUnit.MILLISECONDS) ); result.nseconds = new uint32((int)(1000000 * (gmtMillis % 1000))); return result; } private  HimeraNfsUtils(); static void fill_attributes(Stat stat,  fattr3 at); static void fill_attributes(Stat stat,  wcc_attr at); static nfstime3 convertTimestamp(long gmtMillis); static long convertTimestamp(nfstime3 gmtNanos); static void set_sattr(Inode inode, VirtualFileSystem fs, sattr3 s); static post_op_attr defaultPostOpAttr(); static pre_op_attr defaultPreOpAttr(); static wcc_data defaultWccData();  }
@Test public void testConvertTimestamp() throws Exception { SimpleDateFormat dateFormat = new SimpleDateFormat("dd/MM/yyyy HH:mm:ss.SSS"); dateFormat.setTimeZone(TimeZone.getTimeZone("GMT")); long timestamp = dateFormat.parse("01/02/2003 04:06:06.789").getTime(); nfstime3 converted = HimeraNfsUtils.convertTimestamp(timestamp); Assert.assertEquals(timestamp/1000, converted.seconds.value); Assert.assertEquals(1000000 * (timestamp%1000), converted.nseconds.value); long decoded = HimeraNfsUtils.convertTimestamp(converted); Assert.assertEquals(timestamp, decoded); }