Examples of approximateDuration()


Examples of org.ocpsoft.prettytime.PrettyTime.approximateDuration()

   @Test
   public void testRounding() throws Exception
   {
      PrettyTime t = new PrettyTime(new Date(1000 * 60 * 60 * 3 + 1000 * 60 * 45));
      Duration duration = t.approximateDuration(new Date(0));

      assertEquals("4 hours ago", t.format(duration));
      assertEquals("3 hours ago", t.formatUnrounded(duration));
   }

View Full Code Here

Examples of org.ocpsoft.prettytime.PrettyTime.approximateDuration()

   public void testDecorating() throws Exception
   {
      PrettyTime t = new PrettyTime();
      TimeFormat format = new SimpleTimeFormat().setFutureSuffix("from now").setPastSuffix("ago");

      Duration duration = t.approximateDuration(new Date(System.currentTimeMillis() + 1000));
      assertEquals("some time from now", format.decorate(duration, "some time"));

      duration = t.approximateDuration(new Date(System.currentTimeMillis() - 10000));
      assertEquals("some time ago", format.decorate(duration, "some time"));
   }
View Full Code Here

Examples of org.ocpsoft.prettytime.PrettyTime.approximateDuration()

      TimeFormat format = new SimpleTimeFormat().setFutureSuffix("from now").setPastSuffix("ago");

      Duration duration = t.approximateDuration(new Date(System.currentTimeMillis() + 1000));
      assertEquals("some time from now", format.decorate(duration, "some time"));

      duration = t.approximateDuration(new Date(System.currentTimeMillis() - 10000));
      assertEquals("some time ago", format.decorate(duration, "some time"));
   }

   // Method tearDown() is called automatically after every test method
   @After
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.