Here you can find the source of isDecimalFormatValid(final String pattern)
Parameter | Description |
---|---|
pattern | The candidate String string to test. |
True
if the argument is a valid decimal format , and False
otherwise.
public static boolean isDecimalFormatValid(final String pattern)
//package com.java2s; //License from project: Open Source License import java.text.DecimalFormat; public class Main { /**/*from www. j a va 2 s . c om*/ * Validates a {@link DecimalFormat decimal format}. * * @param pattern * The candidate {@link String string} to test. * @return <code>True</code> if the argument is a valid {@link DecimalFormat * decimal format}, and <code>False</code> otherwise. */ public static boolean isDecimalFormatValid(final String pattern) { boolean result = false; try { new DecimalFormat(pattern); result = true; // pattern must be valid not to have // thrown // an exception } catch (Throwable e) { } return result; } }