Code example for PropertyResourceBundle

0
			"administrator.processes.duration.miliseconds=miliseconds"; 
 
	 
	@Test
	public void testDateCalculations() throws ParseException, IOException {
		PropertyResourceBundle propRes = new PropertyResourceBundle(new StringReader(BUNDLES));
		 
    	String start = "2013/03/04 - 08:13:57";
		String stop = "2013/03/04 - 10:08:20";
        StringBuilder calculated = ProcessViewObject.formatDuration(ProcessViewObject.FORMAT.parse(start).getTime(), ProcessViewObject.FORMAT.parse(stop).getTime(), propRes);
        Assert.assertTrue(calculated.toString().trim().equals("1 hours 54 minutes 23 seconds"));
 
    	start = "2013/03/04 - 08:13:57";
		stop = "2013/03/04 - 08:13:58";
        calculated = ProcessViewObject.formatDuration(ProcessViewObject.FORMAT.parse(start).getTime(), ProcessViewObject.FORMAT.parse(stop).getTime(), propRes);
        Assert.assertTrue(calculated.toString().trim().equals("1 seconds"));
 
    	start = "2013/03/04 - 08:13:57";
		stop = "2013/03/04 - 08:14:58";
        calculated = ProcessViewObject.formatDuration(ProcessViewObject.FORMAT.parse(start).getTime(), ProcessViewObject.FORMAT.parse(stop).getTime(), propRes);
        Assert.assertTrue(calculated.toString().trim().equals("1 minutes 1 seconds"));
 
    	start = "2013/03/04 - 08:13:57";
		stop = "2013/03/04 - 08:14:56";
        calculated = ProcessViewObject.formatDuration(ProcessViewObject.FORMAT.parse(start).getTime(), ProcessViewObject.FORMAT.parse(stop).getTime(), propRes);
        Assert.assertTrue(calculated.toString().trim().equals("59 seconds"));
 
    	start = "2013/03/04 - 08:13:57";
		stop = "2013/03/04 - 09:14:56";
        calculated = ProcessViewObject.formatDuration(ProcessViewObject.FORMAT.parse(start).getTime(), ProcessViewObject.FORMAT.parse(stop).getTime(), propRes);
        Assert.assertTrue(calculated.toString().trim().equals("1 hours 59 seconds"));
 
    	start = "2013/03/04 - 08:13:57";
		stop = "2013/03/04 - 09:16:22";
        calculated = ProcessViewObject.formatDuration(ProcessViewObject.FORMAT.parse(start).getTime(), ProcessViewObject.FORMAT.parse(stop).getTime(), propRes);
        Assert.assertTrue(calculated.toString().trim().equals("1 hours 2 minutes 25 seconds"));
 
    	start = "2013/03/04 - 08:13:57";
		stop = "2013/12/04 - 10:33:22";
        calculated = ProcessViewObject.formatDuration(ProcessViewObject.FORMAT.parse(start).getTime(), ProcessViewObject.FORMAT.parse(stop).getTime(), propRes);
        Assert.assertTrue(calculated.toString().trim().equals("9 days  2 hours 19 minutes 25 seconds"));
	} 
	 
}