Saturday 15 August 2015

spring - Java Digits Validation -


I am using verification in a full attribute:

  @Digits (integer = 6, fraction = 0) private integer ID order;   

But I wanted this feature to have 6 digits.

How can I do this? (JSP + spring + using hibernate)

As you need 6 digits, I think If you need the string for the property in some cases, then you

  public int getIdOrder () {return Integer.parseInt (idOrder)}}   

On String You can use pattern verification. This can happen in this way:

  @ patent (regexp = "\\ d {6}") private string idOrder;   

Another option puts idOrder an integer and creates a string for the string:

  public string getIdOrgetAsString () {String s = "000000" + IDODARE; Return s.sbstring (s.length () - 6); }   

Anyway, there are some options.

No comments:

Post a Comment