removing the 'ago' portion?

Splash Forums PrettyTime Users removing the 'ago' portion?

This topic contains 2 replies, has 2 voices, and was last updated by  mjpowersjr 6 years, 10 months ago.

Viewing 3 posts - 1 through 3 (of 3 total)
  • Author
    Posts
  • #17817

    mjpowersjr
    Participant

    I would like to use pretty time to display a friendly version of the overall duration of past events, without relevance to the current date / time. For Example:

    Task Duration

    Laundry 2 hours

    Where 2 hours is the delta between two dates I have recorded. In this case *how long ago* doesn’t really matter, only *how long* is the delta between two dates. I hope this makes sense. Does prettytime already support this?

    -Thanks in advance

    #20407

    Yes, you need to replace the default message bundle and provide your own on the classpath:

    http://ocpsoft.com/prettytime/#i18n

    Specifically replace this class:

    http://ocpsoft.com/api/ocpsoft-pretty-time/1.0.6/com/ocpsoft/pretty/time/i18n/Resources.html

    Or simply create a new locale that is specific for your use-case:

    com.ocpsoft.pretty.time.i18n.CUSTOM_Resources

    Then set the locale in PrettyTime to:

    PrettyTime p = new PrettyTime(new Locale("CUSTOM"));

    #20408

    mjpowersjr
    Participant

    Worked perfect. Thanks!

Viewing 3 posts - 1 through 3 (of 3 total)

You must be logged in to reply to this topic.

Comments are closed.