Skip to content

Commit

Permalink
Error en format de dates #24
Browse files Browse the repository at this point in the history
  • Loading branch information
gdeignacio-fundaciobit committed Aug 27, 2024
1 parent 94e6f43 commit 988a5c7
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 14 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand All @@ -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);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand All @@ -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);
Expand All @@ -86,21 +87,24 @@ 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);

System.out.println(datosPersonales);

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);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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";

Expand Down Expand Up @@ -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);
Expand Down

0 comments on commit 988a5c7

Please sign in to comment.