Correct way to simulate isbn number in j2ee application

I am trying to use a web application using servlets and jsps and I need to simulate the isbn number of an element in my class, as well as in sleeping mappings. What should be the isbn number type? Long or String? I came across many textbooks that use any of them. isbn is supposedly a 10-digit identifier. Sometimes you come across numbers like 0-85131-041-9, which cannot be long. Some examples use hyphen-free numbers.

So what type should be? Any suggestions?

thank

sign

+3
source share
4 answers

Long / ( , ). , Long . / , Long.

, , Date, / SimpleDateFormat. , / ISBN Java SE API. ( , ). , JSP- (, JSTL <fmt:formatDate>) Java-, EL JSF, @FacesConverter.

- ISBN String, . , .

0

ISBN 13 (. wiki). , String. - :

class ISBN {
  private String isbn;
  public ISBN(String isbn) throws ISBNFormatException {
    // you might want to filter hyphens first, before the check
    if(ISBN.isValid(isbn)) this.isbn = isbn;
    else throw new ISBNFormatException(isbn);
  }
  public static boolean isValid(String s) {
   // validate number here, see wiki
  }
}

, , . , String .

. (, ..). , , ( ) .

+3

ISBN 10 , 12 + ISBN > X

ISBN - 11 10 1. X 10, .

, , , .

ISBN, , . , 12 , , , 10 , , , , 0s . , , , . .

, FAQ, ISBn, .

ISBN :
  1. ISBN-13 "978"
  2. , .
3. , .
4. , ;
5. - ISBN, ISBN.

5 , , .

+3

J2EE, Java , , .

, . , , , , . ( , ISBN , , . , , , .)

, , String long. , , , .

: . .

+1

All Articles