DateBuilder.java

  1. /*
  2.  * GovWay - A customizable API Gateway
  3.  * https://govway.org
  4.  *
  5.  * Copyright (c) 2005-2025 Link.it srl (https://link.it).
  6.  *
  7.  * This program is free software: you can redistribute it and/or modify
  8.  * it under the terms of the GNU General Public License version 3, as published by
  9.  * the Free Software Foundation.
  10.  *
  11.  * This program is distributed in the hope that it will be useful,
  12.  * but WITHOUT ANY WARRANTY; without even the implied warranty of
  13.  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  14.  * GNU General Public License for more details.
  15.  *
  16.  * You should have received a copy of the GNU General Public License
  17.  * along with this program.  If not, see <http://www.gnu.org/licenses/>.
  18.  *
  19.  */

  20. package org.openspcoop2.protocol.engine.builder;

  21. import java.text.SimpleDateFormat;
  22. import java.util.Date;

  23. import org.openspcoop2.utils.date.DateManager;
  24. import org.openspcoop2.utils.date.DateUtils;

  25. /**
  26.  * DateBuilder
  27.  *
  28.  * @author Poli Andrea (apoli@link.it)
  29.  * @author $Author$
  30.  * @version $Rev$, $Date$
  31.  */


  32. public class DateBuilder {
  33.     /**
  34.      * Metodo che si occupa di costruire una stringa formata da una data
  35.      * conforme alla specifica.
  36.      * La Data deve essere formato da :
  37.      * yyyy-MM-ddThh:mm:ss    (es. il 23/03/2005 alle 13:56:01 viene registrato come 2005-03-23T13:56:01)
  38.      *
  39.      * @return un oggetto String contenente la data secondo specifica.
  40.      *
  41.      */
  42.    
  43.     public static String getDate_Format(Date date) {
  44.         if(date == null)
  45.             date = DateManager.getDate();
  46.         SimpleDateFormat dateformat = DateUtils.getSimpleDateFormatMs();
  47.         return dateformat.format(date).replace('_','T');
  48.     }
  49.    
  50.     public String getDate_ProtocolFormat() {
  51.         return getDate_ProtocolFormat(null);
  52.     }
  53.    
  54.     public String getDate_ProtocolFormat(Date date) {
  55.         if(date == null)
  56.             date = DateManager.getDate();
  57.         SimpleDateFormat dateformat = DateUtils.getSimpleDateFormatMs();
  58.         return dateformat.format(date).replace('_','T');
  59.     }

  60. }