Package org.ocpsoft.prettytime

Examples of org.ocpsoft.prettytime.TimeFormat


   {
      bundle = ResourceBundle.getBundle(unit.getResourceBundleName(), locale);

      if (bundle instanceof TimeFormatProvider)
      {
         TimeFormat format = ((TimeFormatProvider) bundle).getFormatFor(unit);
         if (format != null)
         {
            this.override = format;
         }
      }
View Full Code Here


    }

    @Override
    public TimeFormat getFormatFor(TimeUnit t) {
        if (t instanceof JustNow) {
            return new TimeFormat() {
                @Override
                public String format(Duration duration) {
                    return performFormat(duration);
                }
View Full Code Here

    }

    @Override
    public TimeFormat getFormatFor(TimeUnit t) {
        if (t instanceof JustNow) {
            return new TimeFormat() {
                @Override
                public String format(Duration duration) {
                    return performFormat(duration);
                }
View Full Code Here

   @Override
   public TimeFormat getFormatFor(TimeUnit t)
   {
      if (t instanceof Minute)
      {
         return new TimeFormat() {

            @Override
            public String decorate(Duration duration, String time)
            {
               String result = duration.getQuantityRounded(50) > 1 ? time + "i" : "o";
View Full Code Here

   @Test
   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

TOP

Related Classes of org.ocpsoft.prettytime.TimeFormat

Copyright © 2018 www.massapicom. 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.