FileDocCategorySizeDatePackage
TestSystemTimeUtils.javaAPI DocApache Poi 3.0.13004Sun Mar 11 12:59:30 GMT 2007org.apache.poi.hslf.util

TestSystemTimeUtils

public class TestSystemTimeUtils extends TestCase
Tests that SystemTimeUtils works properly.
author
Nick Burch (nick at torchbox dot com)

Fields Summary
private byte[]
data_a
private byte[]
data_b
private SimpleDateFormat
sdf
Constructors Summary
Methods Summary
public voidtestGetDateA()


	     
		Date date = SystemTimeUtils.getDate(data_a);
		
		// Is 2006-01-24 (2nd day of week) 10:26:15.205
		Date exp = sdf.parse("2006-01-24 10:26:15.205");
		assertEquals(exp.getTime(), date.getTime());
		assertEquals(exp, date);
	
public voidtestGetDateB()

		Date date = SystemTimeUtils.getDate(data_b, 8+4);
		
		// Is 2006-01-24 (2nd day of week) 21:25:03.725
		Date exp = sdf.parse("2006-01-24 21:25:03.725");
		assertEquals(exp.getTime(), date.getTime());
		assertEquals(exp, date);
	
public voidtestWriteDateA()

		byte[] out_a = new byte[data_a.length];
		Date date = sdf.parse("2006-01-24 10:26:15.205");
		SystemTimeUtils.storeDate(date, out_a);
		
		for(int i=0; i<out_a.length; i++) {
			assertEquals(data_a[i], out_a[i]);
		}
	
public voidtestWriteDateB()

		byte[] out_b = new byte[data_b.length];
		// Copy over start and end, ignoring the 16 byte date field in the middle
		System.arraycopy(data_b, 0, out_b, 0, 12);
		System.arraycopy(data_b, 12+16, out_b, 12+16, data_b.length-12-16);
		
		Date date = sdf.parse("2006-01-24 21:25:03.725");
		SystemTimeUtils.storeDate(date, out_b, 12);
		
		for(int i=0; i<out_b.length; i++) {
			assertEquals(data_b[i], out_b[i]);
		}