Subversion Repositories eFlore/Applications.coel

Rev

Rev 949 | Rev 965 | Go to most recent revision | Details | Compare with Previous | Last modification | View Log | RSS feed

Rev Author Line No. Line
619 gduche 1
package org.tela_botanica.client.util;
2
 
954 jpm 3
import java.util.Date;
4
 
5
import com.google.gwt.i18n.client.DateTimeFormat;
6
 
619 gduche 7
public class UtilString {
8
 
9
	/**
10
	 *  Mets la première lettre d'une chaine en majuscule
11
	 *
12
	 *  @param chaineDeCaractere
13
	 *  @result ChaineDeCaractere
14
	 */
15
 
16
	public static String ucFirst(String inputStr)	{
798 gduche 17
		if (isEmpty(inputStr))	{
674 gduche 18
			return "";
19
		}
619 gduche 20
		return inputStr.substring(0,1).toUpperCase() + inputStr.substring(1, inputStr.length());
21
	}
798 gduche 22
 
23
	public static boolean isEmpty(String inputStr)	{
24
		return inputStr == null || inputStr.equals("");
25
	}
948 jpm 26
 
27
	public static double formaterEnDouble(String nombre)	{
28
		if (!isEmpty(nombre)) {
29
			return Double.parseDouble(nombre);
30
		}
31
		return new Double(0);
32
	}
949 jpm 33
 
34
	public static int formaterEnEntier(String nombre)	{
35
		if (!isEmpty(nombre)) {
36
			return Integer.parseInt(nombre);
37
		}
38
		return new Integer(0);
39
	}
954 jpm 40
 
41
	public static Date formaterEnDate(String dateChaine)	{
42
		Date date = null;
43
		if (!isEmpty(dateChaine) && !dateChaine.equals("0000-00-00")) {
44
			date = DateTimeFormat.getFormat("yyyy-MM-dd").parseStrict(dateChaine);
45
		}
46
		return date;
47
	}
619 gduche 48
}