From 988a5c7ab2dd6b9a33b6753481bbbe472ec9ecf7 Mon Sep 17 00:00:00 2001 From: gdeignacio-fundaciobit Date: Tue, 27 Aug 2024 14:35:56 +0200 Subject: [PATCH] Error en format de dates #24 --- .../SCDCPAJUv3/api/ScdcpajUv3ApiTest.java | 8 ++++---- .../SCDHPAJUv3/api/ScdhpajUv3ApiTest.java | 20 +++++++++++-------- .../ws/cedent/CedentClient.java | 11 ++++++++-- 3 files changed, 25 insertions(+), 14 deletions(-) diff --git a/SCDCPAJUv3-api-cedent-client/src/test/java/es/caib/scsp/api/cedent/client/SCDCPAJUv3/api/ScdcpajUv3ApiTest.java b/SCDCPAJUv3-api-cedent-client/src/test/java/es/caib/scsp/api/cedent/client/SCDCPAJUv3/api/ScdcpajUv3ApiTest.java index 1ea575a..aafc8c5 100644 --- a/SCDCPAJUv3-api-cedent-client/src/test/java/es/caib/scsp/api/cedent/client/SCDCPAJUv3/api/ScdcpajUv3ApiTest.java +++ b/SCDCPAJUv3-api-cedent-client/src/test/java/es/caib/scsp/api/cedent/client/SCDCPAJUv3/api/ScdcpajUv3ApiTest.java @@ -80,8 +80,8 @@ public void peticionSincronaTest() throws Exception { Solicitud body = new Solicitud(); - String provinciaSolicitud = "7"; - String municipioSolicitud = "26"; + String provinciaSolicitud = "07"; + String municipioSolicitud = "032"; body.setProvinciaSolicitud(provinciaSolicitud); body.setMunicipioSolicitud(municipioSolicitud); @@ -92,8 +92,8 @@ public void peticionSincronaTest() throws Exception { Documentacion.TipoEnum tipo = Documentacion.TipoEnum.NIE; //String valor = "41438576M"; - String valor = "78219106Q"; - //String valor = "Z1000675L"; + //String valor = "78219106Q"; + String valor = "Z1000675L"; documentacion.setTipo(tipo); documentacion.setValor(valor); diff --git a/SCDHPAJUv3-api-cedent-client/src/test/java/es/caib/scsp/api/cedent/client/SCDHPAJUv3/api/ScdhpajUv3ApiTest.java b/SCDHPAJUv3-api-cedent-client/src/test/java/es/caib/scsp/api/cedent/client/SCDHPAJUv3/api/ScdhpajUv3ApiTest.java index d0658e3..5460c0d 100644 --- a/SCDHPAJUv3-api-cedent-client/src/test/java/es/caib/scsp/api/cedent/client/SCDHPAJUv3/api/ScdhpajUv3ApiTest.java +++ b/SCDHPAJUv3-api-cedent-client/src/test/java/es/caib/scsp/api/cedent/client/SCDHPAJUv3/api/ScdhpajUv3ApiTest.java @@ -63,7 +63,8 @@ public void peticionSincronaTest() throws Exception { ApiClient apiClient = api.getApiClient(); - apiClient.setBasePath("http://10.0.0.45:8580/pinbal-services/rest"); + //apiClient.setBasePath("http://10.0.0.45:8580/pinbal-services/rest"); + apiClient.setBasePath("http://Nautilus:48080/emiservcedentapi/externa"); apiClient.setDebugging(true); @@ -74,10 +75,10 @@ public void peticionSincronaTest() throws Exception { apiClient.addDefaultHeader(HttpHeaders.AUTHORIZATION, "Basic " + Base64Utils.encodeToString(userpass.getBytes(StandardCharsets.UTF_8))); - Solicitud body = new Solicitud(); + Solicitud body = new Solicitud(); - String provinciaSolicitud = "7"; - String municipioSolicitud = "26"; + String provinciaSolicitud = "07"; + String municipioSolicitud = "032"; body.setProvinciaSolicitud(provinciaSolicitud); body.setMunicipioSolicitud(municipioSolicitud); @@ -86,9 +87,10 @@ public void peticionSincronaTest() throws Exception { Documentacion documentacion = new Documentacion(); - Documentacion.TipoEnum tipo = Documentacion.TipoEnum.NIF; + Documentacion.TipoEnum tipo = Documentacion.TipoEnum.NIE; //String valor = "41438576M"; - String valor = "43085322C"; + //String valor = "43085322C"; + String valor = "Z1000675L"; documentacion.setTipo(tipo); documentacion.setValor(valor); @@ -96,11 +98,13 @@ public void peticionSincronaTest() throws Exception { Titular titular; titular = new Titular(); - //titular.setDocumentacion(documentacion); - titular.setNia("0702600196105"); + titular.setDocumentacion(documentacion); + //titular.setNia("003200000077866"); + //titular.setNia("0702600196105"); System.out.println(titular); body.setTitular(titular); + body.setNumeroAnyos("20"); System.out.println("==========="); System.out.println(body); diff --git a/emiservbackoffice-ws/emiservbackoffice_ws_server/src/main/java/es/caib/emiservbackoffice/ws/cedent/CedentClient.java b/emiservbackoffice-ws/emiservbackoffice_ws_server/src/main/java/es/caib/emiservbackoffice/ws/cedent/CedentClient.java index 2b49865..ac77811 100644 --- a/emiservbackoffice-ws/emiservbackoffice_ws_server/src/main/java/es/caib/emiservbackoffice/ws/cedent/CedentClient.java +++ b/emiservbackoffice-ws/emiservbackoffice_ws_server/src/main/java/es/caib/emiservbackoffice/ws/cedent/CedentClient.java @@ -14,6 +14,10 @@ * @author gdeignacio */ public abstract class CedentClient { + + private static final String FULL_DATE_STRING = "yyyy-MM-dd hh:mm:ss"; + private static final String DATE_STRING = "yyyy-MM-dd"; + public static String EMISERV_BACKOFFICE_XMLNS = "http://caib.es/emiserv/backoffice"; @@ -80,11 +84,14 @@ protected String fullDateToDate(String fullDate) { if (fullDate==null) return null; String strDate = fullDate; - SimpleDateFormat sdfFullDate = new SimpleDateFormat("yyyy-MM-dd hh:mm:ss"); + + String dateFormat = (fullDate.length() == DATE_STRING.length())? DATE_STRING : FULL_DATE_STRING; + + SimpleDateFormat sdfFullDate = new SimpleDateFormat(dateFormat); Date date; try { date = sdfFullDate.parse(fullDate); - SimpleDateFormat sdfDate = new SimpleDateFormat("yyyy-MM-dd"); + SimpleDateFormat sdfDate = new SimpleDateFormat(dateFormat); strDate = sdfDate.format(date); } catch (ParseException ex) { java.util.logging.Logger.getLogger(CedentClient.class.getName()).log(Level.SEVERE, null, ex);