[jcifs] Equivalent for java.io.File.getCanonicalPath()

Julian Reschke julian.reschke at gmx.de
Tue Feb 3 15:34:15 GMT 2004


Michael B Allen wrote:

>>2) Timezone handling: it seems that timestamps returned by the server
>>are handled in a timezone-aware way. That is, if the client thinks that
>>the timestamp belongs into a time interval where DST was in effect, an
>>additional hour is subtracted.
> 
> 
> CIFS adjusts for timezone and DST and as far as I know jCIFS is fully
> compatible with the expected behavor. Ultimately jCIFS emulates
> Windows2000. If you determine that jCIFS does not do something precisely
> like Windows2000 please let me know.

OK, here's a test that reproduces what I see (and I think this behaviour 
is wrong). Platform is a local file share on a Win2K Professional 
system, configured to automatically switch from/to DST.

	private static final long MS_PER_DAY = 60L * 60L * 24L * 1000L;

	private static void testTimeZones() throws IOException {
		
		long ts = MS_PER_DAY * ((30 * 365) + 180); // date in summer
		
		File fsummer = new File(localfolder + "fsummer");
		fsummer.createNewFile();
		System.out.println("setting to: " + ts);
		fsummer.setLastModified(ts);
		System.out.println("file summer lastmod: " + fsummer.lastModified());
	
		SmbFile smb = new SmbFile("smb://" + creds + host + "/" + share + 
"/fsummer");
		System.out.println("smb summer lastmod: " + smb.lastModified());
		
		ts = MS_PER_DAY * (30 * 365);
		
		File fwinter = new File(localfolder + "fwinter");
		fwinter.createNewFile();
		System.out.println("setting to: " + ts);
		fwinter.setLastModified(ts);
		System.out.println("file winter lastmod: " + fwinter.lastModified());
		
		smb = new SmbFile("smb://" + creds + host + "/" + share + "/fwinter");
		System.out.println("smb winter lastmod: " + smb.lastModified());
		
	}

Yields:

setting to: 961632000000
file summer lastmod: 961632000000
smb summer lastmod: 961628400000
setting to: 946080000000
file winter lastmod: 946080000000
smb winter lastmod: 946080000000

So for timestamps that fall into a DST period I'm getting a difference 
of 1 hour compared to java.io.File, while the timestamps do match for a 
timestamp outside DST.

Regards, Julian

-- 
<green/>bytes GmbH -- http://www.greenbytes.de -- tel:+492512807760


More information about the jcifs mailing list