Avalados por :

Cómo formatear el SourceFileTimestamp en MM/dd/yyyy hh:mm:ss para un correo electrónico

  • Creado 01/03/2024
  • Modificado 01/03/2024
  • 2 Vistas
0
Cargando...

Hola,

Necesito tomar el SourceFileTimestamp y pasarlo en el cuerpo del correo como texto.

Necesito que esta fecha esté en un formato específico que es - MM/dd/yyyy hh:mm:ss

La fecha viene como - YYYYMMDDTHHMMSSZ de ASMA SourceFileTimestamp

donde T representa el inicio del tiempo y Z representa el final del tiempo.

Mi código es el siguiente pero está dando error -

java.lang.StringIndexOutOfBoundsException: String index out of range: -2

try{

DynamicConfiguration conf = (DynamicConfiguration)
container.getTransformationParameters().get(StreamTransformationConstants.DYNAMIC_CONFIGURATION);

DynamicConfigurationKey key1 = DynamicConfigurationKey.create(" _http://sap.com/xi/XI/System/File","FileName ");

DynamicConfigurationKey key2 = DynamicConfigurationKey.create(" _http://sap.com/xi/XI/System/File","SourceFileTimestamp ");

String fname= conf.get(key1);

String timestamp= conf.get(key2);

String Str= timestamp;

String date= Str.substring(0, 8);

String year= date.substring(0, 4);
String month= date.substring(4, 2);
String day= date.substring(6, 2);

String time= Str.substring(9, 6);

String hours= time.substring(9, 2);
String mins= time.substring(11, 2);
String secs= time.substring(13, 2);

String date1= month+" / "+day+" / "+year;
String time1= hours+" : "+mins+" : "+secs;

String filename= "Archivo EBS con nombre de archivo " + fname + " se recibió correctamente en SAP @ " +date1+" "+time1;

return "Estimado/a Señor/a," +" \n " +" \n "+filename;

}

catch(Exception e)

{

String exception = e.toString();

return exception;

}

Por favor, corrija esta UDF.

Gracias

Neha

Pedro Pascal
Se unió el 07/03/2018
Pinterest
Telegram
Linkedin
Whatsapp

4 Respuestas

0
Cargando...

Hola Rajesh,

He corregido el udf, por favor prueba esto:

DynamicConfiguration conf = (DynamicConfiguration)

container.getTransformationParameters().get(StreamTransformationConstants.DYNAMIC_CONFIGURATION);

DynamicConfigurationKey key = DynamicConfigurationKey.create(" http://sap.com/xi/XI/System/File ","SourceFileTimestamp");

String timestamp= conf.get(key);

String Str= timestamp;

String date= Str.substring(0, 8);

String year= date.substring(0, 4);

String month= date.substring(4, 6);

String day= date.substring(6);

String time= Str.substring(8,16);

String hours= time.substring(1,3);

String mins= time.substring(3,5);

String secs= time.substring(5,7);

String date1= year + month + day;

String time1= hours+":"+mins+":"+secs;

timestamp = date1 + " " + time1;

return timestamp;

Respondido el 15/04/2024
LUCIANO RIOJA GHIOTTO
Se unió el 13/07/2019
0
Cargando...

Hola Vishnu,

Para la marca de tiempo también estoy obteniendo un error con el siguiente código;

Necesito el formato de tiempo como YYYYMMDD HH:MM:SS

public String GET_XMLtime(Container container){

DynamicConfiguration conf = (DynamicConfiguration)

container.getTransformationParameters().get(StreamTransformationConstants.DYNAMIC_CONFIGURATION);

DynamicConfigurationKey key = DynamicConfigurationKey.create(" http://sap.com/xi/XI/System/File ","SourceFileTimestamp");

String timestamp= conf.get(key);

String Str= timestamp;

String date= Str.substring(0, 8);

String year= date.substring(0, 4);

String month= date.substring(4, 6);

String day= date.substring(6);

String time= Str.substring(8);

String hours= time.substring(9, 11);

String mins= time.substring(11, 13);

String secs= time.substring(13, 15);

String date1= month+" / "+day+" / "+year;

String time1= hours+" : "+mins+" : "+secs;

return timestamp;

Respondido el 15/04/2024
LUCIANO RIOJA GHIOTTO
Se unió el 13/07/2019
0
Cargando...

Hola Neha,

Por favor, prueba este código:

try{

DynamicConfiguration conf = (DynamicConfiguration)

container.getTransformationParameters().get(StreamTransformationConstants.DYNAMIC_CONFIGURATION);

DynamicConfigurationKey key1 = DynamicConfigurationKey.create("_ http://sap.com/xi/XI/System/File ","FileName");

DynamicConfigurationKey key2 = DynamicConfigurationKey.create("_ http://sap.com/xi/XI/System/File ","SourceFileTimestamp");

String fname= conf.get(key1);

String timestamp= conf.get(key2);

String Str= timestamp;

String date= Str.substring(0, 8);

String year= date.substring(0, 4);

String month= date.substring(4, 6);

String day= date.substring(6);

String time= Str.substring(8);

String hours= time.substring(9, 11);

String mins= time.substring(11, 13);

String secs= time.substring(13, 15);

String date1= month+" / "+day+" / "+year;

String time1= hours+" : "+mins+" : "+secs;

String filename= "Archivo EBS con nombre de archivo " + fname + " se recibió correctamente en SAP @ " +date1+"  "+time1;

return "Estimado Señor / Señora," +" \n " +" \n "+filename;

}

catch(Exception e)

{

String exception = e.toString();

return exception;

}

Solo corregí las líneas de substring en tu código.

Saludos

Vishnu

Respondido el 15/04/2024
LUCIANO RIOJA GHIOTTO
Se unió el 13/07/2019
0
Cargando...

Hola Neha,

He corregido el udf, pruébalo así:

try{

DynamicConfiguration conf = (DynamicConfiguration)

container.getTransformationParameters().get(StreamTransformationConstants.DYNAMIC_CONFIGURATION);

DynamicConfigurationKey key1 = DynamicConfigurationKey.create("_ http://sap.com/xi/XI/System/File ","FileName");

DynamicConfigurationKey key2 = DynamicConfigurationKey.create("_ http://sap.com/xi/XI/System/File ","SourceFileTimestamp");

String fname= conf.get(key1);

String timestamp= conf.get(key2);

String Str= timestamp;

String date= Str.substring(0, 8);

String year= date.substring(0, 4);

String month= date.substring(4, 6);

String day= date.substring(6);

String time= Str.substring(8);

String hours= time.substring(1,3);

String mins= time.substring(3,5);

String secs= time.substring(5,7);

String date1= month+" / "+day+" / "+year;

String time1= hours+" : "+mins+" : "+secs;

String filename= "Archivo EBS con nombre de archivo " + fname + " se recibió correctamente en SAP @ " +date1+" "+time1;

return "Estimado/a Señor/a," +" \n " +" \n "+filename;

}

catch(Exception e)

{

String exception = e.toString();

return exception;

}

Saludos

Vishnu

Respondido el 15/04/2024
LUCIANO RIOJA GHIOTTO
Se unió el 13/07/2019

contacto@primeinstitute.com

(+51) 1641 9379
(+57) 1489 6964

© 2024 Copyright. Todos los derechos reservados.

Desarrollado por Prime Institute

¡Hola! Soy Diana, asesora académica de Prime Institute, indícame en que curso estas interesado, saludos!
Hola ¿Puedo ayudarte?