gwt DateTimeFormat
/* * * Copyright (C) 2008 Jose Javier Garca Zornoza. * * Este es un programa libre; puedes distribuirlo y/o modificarlo bajo * los trminos de la versin 2 (o cualquier versin posterior) de la Licencia * Pblica General de la Fundacin de Software Libre. * Este programa se distribuye con la esperanza de poder ser til, pero sin * NINGUNA GARANTIA; tampoco la garanta implcita de COMERCIALIZACION o DEDICACIN * A UN PROPOSITO PARTICULAR. Ver la licencia GNU GPL para ms detalles. * Deberas haber recibido una copia de la licencia GNU GPL con este programa; * en caso contrario puedes obtener una copia visitando el sitio web www.fsf.org * o escribiendo a la Fundacin de Software Libre, Inc., 59 Temple * Place - Suite 330, Boston, MA 02111-1307, USA. * */ package org.gruposp2p.dnie.client.util; import java.util.Date; import com.google.gwt.i18n.client.DateTimeFormat; public class DateUtils { /** * Mtodo que devuelve un Date a partir de un String con formato "yyyy-MM-ddTHH:mm:ss" * * @param dateString fecha en formato String * @return Date fecha en formato Date * @throws import java.text.ParseException; */ public static Date getDateFromString (String dateString) { DateTimeFormat formatter = DateTimeFormat.getFormat("yyyy-MM-ddTHH:mm:ss"); return formatter.parse(dateString); } /** * Mtodo que devuelve un String con formato "yyyy-MM-dd'T'HH:mm:ss a partir de un Date" * * @param Date fecha en formato Date * @return dateString fecha en formato String * @throws import java.text.ParseException; */ public static String getStringFromDate (Date date) { DateTimeFormat formatter = DateTimeFormat.getFormat("yyyy-MM-dd'T'HH:mm:ss"); return formatter.format(date); } public static String getSimpleStringFromDate (Date date) { DateTimeFormat formatter = DateTimeFormat.getFormat("yyyy-MM-dd"); return formatter.format(date); } }