class DateUtils {

    public static Duration getDuration( String duration )
    {
        Matcher matcher = DURATION_PATTERN.matcher( duration );

        if ( !matcher.find() )
        {
            return null;
        }

        long amount = Long.valueOf( matcher.group( 1 ) );
        String unit = matcher.group( 2 );

        ChronoUnit chronoUnit = TEMPORAL_MAP.get( unit );

        if ( chronoUnit == null )
        {
            return null;
        }

        return Duration.of( amount, chronoUnit );
    }

}