Parses the specified string as a double-precision floating point value. The ASCII character {@code '-'} (<code>'\u002D'</code>) is recognized as the minus sign. <p>Unlike {@link Double#parseDouble(String)}, this method returns {@code null} instead of throwing an exception if parsing fails. Vali
(String string)
| 766 | * @since 14.0 |
| 767 | */ |
| 768 | @GwtIncompatible // regular expressions |
| 769 | public static @Nullable Double tryParse(String string) { |
| 770 | if (FLOATING_POINT_PATTERN.matcher(string).matches()) { |
| 771 | // TODO(lowasser): could be potentially optimized, but only with |
| 772 | // extensive testing |
| 773 | try { |
| 774 | return parseDouble(string); |
| 775 | } catch (NumberFormatException e) { |
| 776 | // Double.parseDouble has changed specs several times, so fall through |
| 777 | // gracefully |
| 778 | } |
| 779 | } |
| 780 | return null; |
| 781 | } |
| 782 | } |