java - Validation to check a double for 2 decimal places -


I am checking an example in Java to see that a double amount has been entered by the user, in which Includes two decimal places eg 99.99 entered will be valid and 99.9 or 99.999 will be returned invalid.

  double D = 234.12413; String [] splitter = d.toString (). the division ("\\."); Separator [0] .length (); // Decimal decimal length before split = splitter [1]. Length (); // For the question of Henry, after decimal decimal == 2 // // other invalid // invalid   

  double D1 = 0.50; Double D2 = D1% 1; Decimalable df = new decimal time ("# 00."); Int decimalLength = (df.format (d2) .length () - 1); If (Dynamic Language == 2) // Valid and // Invalid   

Note: df.format (d2) Return .50 , Therefore length is 3

Comments

Popular posts from this blog

c - Mpirun hangs when mpi send and recieve is put in a loop -

python - Apply coupon to a customer's subscription based on non-stripe related actions on the site -

java - Unable to get JDBC connection in Spring application to MySQL -