title: Version Comparator 3 decimal places
body: <p>Hello I am trying to compare version numbers of phone devices. My program is was crashing if a version comes in as 4.3.2 so I implemented Decimal format but now it just rounds my number from 4.3.2 to 4.3, but the program will be completely fine with a version number of something like 4.2 for example. How can I fix my comparator to be able to take in 3 decimals and not crash while still working for 2 decimals as well.  </p>
  
  <pre><code>        @Override
          public int compare(InventoryCardViewModel lhs, InventoryCardViewModel rhs) {
  
              Phone lhp = phoneDataSource.getPhoneByDeviceID(lhs.getPhoneDeviceID.getValue());
              Phone rhp = phoneDataSource.getPhoneByDeviceID(rhs.getPhoneDeviceID.getValue());
  
              if(!lhp.versionNumber.equals(rhp.versionNumber)) {
                  DecimalFormat df =  new DecimalFormat("#.#.#", new DecimalFormatSymbols(new Locale("en_US")));
                  try {
                      lhp.versionNumber = String.valueOf(df.parse(lhp.versionNumber).doubleValue());
                      rhp.versionNumber = String.valueOf(df.parse(lhp.versionNumber).doubleValue());
                  } catch (ParseException e) {
                      e.printStackTrace();
                  }
                  if (Double.valueOf(lhp.versionNumber) &gt; Double.valueOf(rhp.versionNumber)) {
                      return -1;
                  } else {
                      return 1;
                  }
  </code></pre>