Subversion Repositories eFlore/Applications.coel

Rev

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

package org.tela_botanica.client.util;

import java.util.Date;

import com.google.gwt.i18n.client.DateTimeFormat;

public class UtilString {
        
        /**
         *  Mets la première lettre d'une chaine en majuscule
         *  
         *  @param chaineDeCaractere
         *  @result ChaineDeCaractere
         */
        
        public static String ucFirst(String inputStr)   {
                if (isEmpty(inputStr))  {
                        return "";
                }
                return inputStr.substring(0,1).toUpperCase() + inputStr.substring(1, inputStr.length());
        }
        
        public static boolean isEmpty(String inputStr)  {
                return inputStr == null || inputStr.equals("");
        }
        
        public static double formaterEnDouble(String nombre)    {
                if (!isEmpty(nombre)) {
                        return Double.parseDouble(nombre);
                }
                return new Double(0);
        }
        
        public static int formaterEnEntier(String nombre)       {
                if (!isEmpty(nombre)) {
                        return Integer.parseInt(nombre);
                }
                return new Integer(0);
        }
        
        public static Date formaterEnDate(String dateChaine)    {
                Date date = null;
                if (!isEmpty(dateChaine) && !dateChaine.equals("0000-00-00")) {
                        date = DateTimeFormat.getFormat("yyyy-MM-dd").parseStrict(dateChaine);
                }
                return date;
        }
}