File src/de/openrat/client/util/NumberUtils.java

Last commit: Fri Sep 30 23:38:24 2016 +0200	dankert	Parsen der Server-Notices und füllen der CMSResponse. Weitere Doku mit JavaDoc.
1 package de.openrat.client.util; 2 3 public class NumberUtils 4 { 5 /** 6 * Null-safe and Exception-safe conversion from {@link String} to 7 * {@link Integer}. 8 * 9 * @param number 10 * Number 11 * @return int (0, if number is not a number) 12 */ 13 public static int toInt(String number) 14 { 15 try 16 { 17 return Integer.parseInt(number); 18 } 19 catch (NumberFormatException e) 20 { 21 return 0; 22 } 23 } 24 25 /** 26 * Null-safe and Exception-safe conversion from {@link String} to 27 * {@link Long}. 28 * 29 * @param number 30 * Number 31 * @return int (0, if number is not a number) 32 */ 33 public static long toLong(String number) 34 { 35 try 36 { 37 return Long.parseLong(number); 38 } 39 catch (NumberFormatException e) 40 { 41 return 0; 42 } 43 } 44 45 }
Download src/de/openrat/client/util/NumberUtils.java
History Fri, 30 Sep 2016 23:38:24 +0200 dankert Parsen der Server-Notices und füllen der CMSResponse. Weitere Doku mit JavaDoc. Fri, 30 Sep 2016 22:45:01 +0200 dankert first version of the java api.