SPCoopUtils.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.spcoop.utils;

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

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

  25. /**
  26.  * Utilities per il protocollo SPCoop
  27.  *
  28.  * @author Poli Andrea (apoli@link.it)
  29.  * @author $Author$
  30.  * @version $Rev$, $Date$
  31.  */
  32. public class SPCoopUtils {
  33.    
  34.     /**
  35.      * Metodo che si occupa di costruire una stringa formata da una data
  36.      * conforme alla specifica eGov.
  37.      * La Data deve essere formato da :
  38.      * yyyy-MM-ddThh:mm:ss    (es. il 23/03/2005 alle 13:56:01 viene registrato come 2005-03-23T13:56:01)
  39.      *
  40.      * @return un oggetto String contenente la data secondo specifica eGov.
  41.      *
  42.      */
  43.     public static String getDate_eGovFormat() {
  44.         return getDate_eGovFormat(org.openspcoop2.utils.date.DateManager.getDate());
  45.     }
  46.        
  47.     public static String getDate_eGovFormat(Date date) {
  48.         SimpleDateFormat dateformat = DateUtils.getSimpleDateFormatMs();
  49.         return dateformat.format(date).replace('_','T');
  50.     }
  51.    
  52.     public static Date getDate_eGovFormat(String date) throws ParseException {
  53.         SimpleDateFormat dateformat = DateUtils.getSimpleDateFormatMs();
  54.         return dateformat.parse(date.replace('T','_'));
  55.     }
  56. }