Package org.clapper.util.text

Examples of org.clapper.util.text.Duration


        formatOne(864001001, "10 days, 1 second, 1 millisecond");
    }

    private void parseOne(String s, long expected) throws Exception
    {
        Duration d = new Duration(s);
        assertEquals("Parse of \"" + s + "\" did not produce correct result",
                     expected, d.getDuration());
    }
View Full Code Here


                     expected, d.getDuration());
    }

    private void formatOne(long ms, String expected) throws Exception
    {
        Duration d = new Duration(ms);
        assertEquals("Format of " + expected + " did not produce expected " +
                     "result.", expected, d.format());
    }
View Full Code Here

            Locale localeIn = getLocale(desiredInputLocale);
            Locale localeOut = getLocale(desiredOutputLocale);

            for (String s : stringsToParse)
            {
                Duration duration = null;

                try
                {
                    long l = Long.parseLong(s);
                    duration = new Duration(l);
                }

                catch (NumberFormatException ex)
                {
                    System.out.println("\nParsing \"" + s + "\"");

                    try
                    {
                        duration = new Duration(s, localeIn);
                        System.out.println("Parses to " + duration.getDuration() +
                                           " milliseconds.");
                    }

                    catch (ParseException ex2)
                    {
                        System.err.println("\"" + s + "\" is a bad duration " +
                            "string: " + ex2.getMessage());
                    }
                }

                System.out.println("Duration " + duration.toString() +
                                   " formats to \"" +
                                   duration.format(localeOut) + "\"");
            }
        }

        catch (Exception ex)
        {
View Full Code Here

TOP

Related Classes of org.clapper.util.text.Duration

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.