public long displaySizeToByteCount( String displaySize ) {
    long returnValue = -1;
    // replace "," for int'l decimal convention
    String displaySizeDecimal = ( displaySize == null ) ? "" : displaySize.replace( ",", "." );
    Pattern pattern = Pattern.compile( "([\\d.]+)([GMK]?B)", Pattern.CASE_INSENSITIVE );
    Matcher matcher = pattern.matcher( displaySizeDecimal );
    Map<String, Integer> powerMap = new HashMap<>();
    powerMap.put( "GB", 3 );
    powerMap.put( "MB", 2 );
    powerMap.put( "KB", 1 );
    powerMap.put( "B", 0 );
    if ( matcher.find() ) {
      String number = matcher.group( 1 );
      int pow = powerMap.get( matcher.group( 2 ).toUpperCase() );
      BigDecimal bytes = new BigDecimal( number );
      bytes = bytes.multiply( BigDecimal.valueOf( 1024 ).pow( pow ) );
      returnValue = bytes.longValue();
    }
    return returnValue;
  }
@Test
  public void displaySizeToByteCount_wholeNumbers() {

    StorageUnitConverter storageUnitConverter = new StorageUnitConverter();

    // TEST 1: whole number Byte
    assertEquals( 34 * B, storageUnitConverter.displaySizeToByteCount( "34B" ) );

    // TEST 2: whole number kilobyte
    assertEquals( 121 * KB, storageUnitConverter.displaySizeToByteCount( "121KB" ) );

    // TEST 3: whole number megabyte
    assertEquals( 5 * MB, storageUnitConverter.displaySizeToByteCount( "5MB" ) );

    // TEST 4: whole number gigabyte
    assertEquals( 2 * GB, storageUnitConverter.displaySizeToByteCount( "2GB" ) );

    // TEST 5: missing number
    assertEquals( -1, storageUnitConverter.displaySizeToByteCount( "GB" ) );

    // TEST 6: missing number
    assertEquals( -1, storageUnitConverter.displaySizeToByteCount( "B" ) );

    // TEST 7: letter for number
    assertEquals( -1, storageUnitConverter.displaySizeToByteCount( "XGB" ) );

    // TEST 8: 0
    assertEquals( 0, storageUnitConverter.displaySizeToByteCount( "0KB" ) );

    // TEST 9: empty string
    assertEquals( -1L, storageUnitConverter.displaySizeToByteCount( "" ) );

    // TEST 10: null
    assertEquals( -1L, storageUnitConverter.displaySizeToByteCount( null ) );
  }