Subversion Repositories eFlore/Applications.coel

Rev

Rev 954 | Rev 975 | 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
 
965 jpm 23
	public static boolean isEmpty(String chaine)	{
24
		boolean etreVide = false;
25
		if (chaine == null || chaine.equals("") || chaine.equals("0000-00-00") || chaine.equals("0000-00-00 00:00:00")) {
26
			etreVide = true;
27
		}
28
		return etreVide;
798 gduche 29
	}
948 jpm 30
 
31
	public static double formaterEnDouble(String nombre)	{
32
		if (!isEmpty(nombre)) {
33
			return Double.parseDouble(nombre);
34
		}
35
		return new Double(0);
36
	}
949 jpm 37
 
38
	public static int formaterEnEntier(String nombre)	{
39
		if (!isEmpty(nombre)) {
40
			return Integer.parseInt(nombre);
41
		}
42
		return new Integer(0);
43
	}
954 jpm 44
 
45
	public static Date formaterEnDate(String dateChaine)	{
46
		Date date = null;
47
		if (!isEmpty(dateChaine) && !dateChaine.equals("0000-00-00")) {
48
			date = DateTimeFormat.getFormat("yyyy-MM-dd").parseStrict(dateChaine);
49
		}
50
		return date;
51
	}
619 gduche 52
}