PrettyTime: Social-style time formatting for Java

Discussions

News: PrettyTime: Social-style time formatting for Java

  1. You can also follow @ocpsoft and @lincolnthree on twitter for more updates on PrettyTime Simple example of PrettyTime in Action: ---------------------------------------------------------- import java.util.Date; import com.ocpsoft.pretty.time.PrettyTime; public class BasicJavaApp {    public static void main(String[] args)    {       PrettyTime p = new PrettyTime();       System.out.println(p.format(new Date()));    } } --------------------------------------------------------- Prints: "right now" --------------------------------------------------------- Easy! Visit the PrettyTime website for downloads and more information. Other open-source libraries from @ocpsoft -- PrettyFaces -- bookmarkable URLs for JSF1.2 and JSF2.0

    Threaded Messages (8)

  2. I18n?[ Go to top ]

    The library looks interesting, but it's a pity one would need to shoe-horn internationalization on top of it.
  3. i18n[ Go to top ]

    i18n is in the works -- never fear -- suggestions welcome, also.
  4. I would absolutely use this library if i18n was supported. Simply allow message.properties phrases to be used so we can provide our own translations for all the different possible time outputs.
  5. not my case[ Go to top ]

    PrettyTime p = new PrettyTime(); System.out.println(p.format(new Date())); causes Exception in thread "main" java.lang.ArithmeticException: / by zero at com.ocpsoft.pretty.time.PrettyTime.calculateDuration(PrettyTime.java:114) at com.ocpsoft.pretty.time.PrettyTime.approximateDuration(PrettyTime.java:85) at com.ocpsoft.pretty.time.PrettyTime.format(PrettyTime.java:192) at de.dani.experiments.demos.prettytime.PrettyTimeDemo.main(PrettyTimeDemo.java:11)
  6. Nice finding..this is how the application need to improved. I know many people wrote their own logic to achieve this. This sort of simple tools/API makes development time faster and more over we don't have to think too much on all use-cases(already tested by many people). Contribution & sharing is well appreciated !
  7. Looks like a simple and useful API. I can see people using this. Well done.
  8. i18n[ Go to top ]

    +1 for i18n, able to help with Russian and Ukrainian versions. Feel free to contact me.
  9. Time period[ Go to top ]

    Another idea is to provide similar formatter for time periods. E.g. "2 days", "15 minutes" etc. How about this?