Package org.ocpsoft.prettytime

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


     *
     * @return
     */
    public static final String prettyTime(Date date) {
        PrettyTime p = new PrettyTime();
        return p.format(date);

    }

    public static final String prettyTime(long millisecond) {
        PrettyTime p = new PrettyTime();
View Full Code Here


    }

    public static final String prettyTime(long millisecond) {
        PrettyTime p = new PrettyTime();
        return p.format(new Date(millisecond));
    }

    public static void main(String[] args) {
        System.out.println(PrettyTimeUtils.prettyTime(new Date()));
        System.out.println(PrettyTimeUtils.prettyTime(123));
View Full Code Here

     * @return
     */
    public static String getHowLongAgoDescription(Date then) {
        Locale locale = Locale.getDefault();
        PrettyTime p = new PrettyTime(locale);
        return p.format(then);
    }

    public static String getTimeRemainingDescription(long durationInMillis) {
        Period period = new Period(durationInMillis);
        if (period.toStandardMinutes().getMinutes() <= 0) {
View Full Code Here

    @Test
    public void testRightNow() throws Exception
    {
        PrettyTime t = new PrettyTime(new Date(0), locale);
        assertEquals("hetke pärast", t.format(new Date(6000)));
    }

    @Test
    public void testMomentsAgo() throws Exception
    {
View Full Code Here

    @Test
    public void testMomentsAgo() throws Exception
    {
        PrettyTime t = new PrettyTime(new Date(6000), locale);
        assertEquals("hetk tagasi", t.format(new Date(0)));
    }
   
    @Test
    public void testMilliSecondsFromNow() throws Exception
    {
View Full Code Here

   
    @Test
    public void testMilliSecondsFromNow() throws Exception
    {
        PrettyTime t = newPrettyTimeWOJustNow(new Date(0), locale);
        assertEquals("13 millisekundi pärast", t.format(new Date(13)));
    }

    @Test
    public void testMilliSecondsAgo() throws Exception
    {
View Full Code Here

    @Test
    public void testMilliSecondsAgo() throws Exception
    {
        PrettyTime t = newPrettyTimeWOJustNow(new Date(13), locale);
        assertEquals("13 millisekundit tagasi", t.format(new Date(0)));
    }

    @Test
    public void testMilliSecondFromNow() throws Exception
    {
View Full Code Here

    @Test
    public void testMilliSecondFromNow() throws Exception
    {
        PrettyTime t = newPrettyTimeWOJustNow(new Date(0), locale);
        assertEquals("millisekundi pärast", t.format(new Date(1)));
    }

    @Test
    public void testMilliSecondAgo() throws Exception
    {
View Full Code Here

    @Test
    public void testMilliSecondAgo() throws Exception
    {
        PrettyTime t = newPrettyTimeWOJustNow(new Date(1), locale);
        assertEquals("millisekund tagasi", t.format(new Date(0)));
    }
   
    @Test
    public void testSecondsFromNow() throws Exception
    {
View Full Code Here

   
    @Test
    public void testSecondsFromNow() throws Exception
    {
        PrettyTime t = newPrettyTimeWOJustNow(new Date(0), locale);
        assertEquals("13 sekundi pärast", t.format(new Date(1000 * 13)));
    }

    @Test
    public void testSecondsAgo() throws Exception
    {
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.