diff --git a/libreplan-webapp/src/main/java/org/libreplan/web/common/typeconverters/DateTimeConverter.java b/libreplan-webapp/src/main/java/org/libreplan/web/common/typeconverters/DateTimeConverter.java new file mode 100644 index 000000000..8e23c4241 --- /dev/null +++ b/libreplan-webapp/src/main/java/org/libreplan/web/common/typeconverters/DateTimeConverter.java @@ -0,0 +1,47 @@ +/* + * This file is part of LibrePlan + * + * Copyright (C) 2012 WirelessGalicia, S.L. + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + */ + +package org.libreplan.web.common.typeconverters; + +import java.text.SimpleDateFormat; +import java.util.Date; + +import org.zkoss.zk.ui.Component; +import org.zkoss.zkplus.databind.TypeConverter; + +/** + * Converter for the type java.util.Date with an hour minute precision + * + * @author Susana Montes Pedreira + * + */ +public class DateTimeConverter implements TypeConverter { + + @Override + public Object coerceToBean(Object arg0, Component arg1) { + return null; + } + + @Override + public Object coerceToUi(Object object, Component component) { + return object != null ? (new SimpleDateFormat("dd/MM/yyyy HH:mm")) + .format((Date) object) : new String(""); + } + +} diff --git a/libreplan-webapp/src/main/java/org/libreplan/web/subcontract/CustomerCommunicationCRUDController.java b/libreplan-webapp/src/main/java/org/libreplan/web/subcontract/CustomerCommunicationCRUDController.java index cf3851148..7fbf91842 100644 --- a/libreplan-webapp/src/main/java/org/libreplan/web/subcontract/CustomerCommunicationCRUDController.java +++ b/libreplan-webapp/src/main/java/org/libreplan/web/subcontract/CustomerCommunicationCRUDController.java @@ -21,7 +21,6 @@ package org.libreplan.web.subcontract; import static org.libreplan.web.I18nHelper._; -import java.text.DateFormat; import java.text.SimpleDateFormat; import java.util.Date; import java.util.List; @@ -141,21 +140,24 @@ public class CustomerCommunicationCRUDController extends GenericForwardComposer appendLabel(row, toString(type)); appendLabel(row, customerCommunication.getOrder().getName()); - appendLabel(row, toString(customerCommunication.getDeadline())); + appendLabel(row, + toString(customerCommunication.getDeadline(), "dd/MM/yyyy")); appendLabel(row, customerCommunication.getOrder().getCode()); appendLabel(row, customerCommunication.getOrder() .getCustomerReference()); appendLabel(row, - toString(customerCommunication.getCommunicationDate())); + toString(customerCommunication.getCommunicationDate(), + "dd/MM/yyyy HH:mm")); appendCheckbox(row, customerCommunication); appendOperations(row, customerCommunication); } - private String toString(Date date) { + private String toString(Date date, String precision) { if (date == null) { return ""; } - return new SimpleDateFormat("dd/MM/yyyy", Locales.getCurrent()).format(date); + return new SimpleDateFormat(precision, Locales.getCurrent()) + .format(date); } private String toString(Object object) { diff --git a/libreplan-webapp/src/main/webapp/orders/_edition.zul b/libreplan-webapp/src/main/webapp/orders/_edition.zul index 80e790c41..23c5d1cf2 100644 --- a/libreplan-webapp/src/main/webapp/orders/_edition.zul +++ b/libreplan-webapp/src/main/webapp/orders/_edition.zul @@ -229,7 +229,7 @@