public static long parseDuration(final String propertyName, final String propertyValue)
    {
        final char lastCharacter = propertyValue.charAt(propertyValue.length() - 1);
        if (Character.isDigit(lastCharacter))
        {
            return Long.parseLong(propertyValue);
        }

        if (lastCharacter != 's' && lastCharacter != 'S')
        {
            throw new NumberFormatException(
                propertyName + ": " + propertyValue + " should end with: s, ms, us, or ns.");
        }

        final char secondLastCharacter = propertyValue.charAt(propertyValue.length() - 2);
        if (Character.isDigit(secondLastCharacter))
        {
            final long value = AsciiEncoding.parseLongAscii(propertyValue, 0, propertyValue.length() - 1);
            return TimeUnit.SECONDS.toNanos(value);
        }

        final long value = AsciiEncoding.parseLongAscii(propertyValue, 0, propertyValue.length() - 2);

        switch (secondLastCharacter)
        {
            case 'n':
            case 'N':
                return value;

            case 'u':
            case 'U':
                return TimeUnit.MICROSECONDS.toNanos(value);

            case 'm':
            case 'M':
                return TimeUnit.MILLISECONDS.toNanos(value);

            default:
                throw new NumberFormatException(
                    propertyName + ": " + propertyValue + " should end with: s, ms, us, or ns.");
        }
    }
@Test
    void shouldParseTimesWithSuffix()
    {
        assertEquals(1L, parseDuration("", "1"));
        assertEquals(1L, parseDuration("", "1ns"));
        assertEquals(1L, parseDuration("", "1NS"));
        assertEquals(1000L, parseDuration("", "1us"));
        assertEquals(1000L, parseDuration("", "1US"));
        assertEquals(1000L * 1000, parseDuration("", "1ms"));
        assertEquals(1000L * 1000, parseDuration("", "1MS"));
        assertEquals(1000L * 1000 * 1000, parseDuration("", "1s"));
        assertEquals(1000L * 1000 * 1000, parseDuration("", "1S"));
        assertEquals(12L * 1000 * 1000 * 1000, parseDuration("", "12S"));
    }