Avalados por :

Como formatar o SourceFileTimestamp em MM/dd/yyyy hh:mm:ss para um email

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

Olá,

Preciso pegar o SourceFileTimestamp e colocá-lo no corpo do e-mail como texto.

Preciso que esta data esteja em um formato específico que é - MM/dd/yyyy hh:mm:ss

A data vem como - YYYYMMDDTHHMMSSZ do ASMA SourceFileTimestamp

onde T representa o início do tempo e Z representa o final do tempo.

Meu código é o seguinte, mas está dando erro -

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= "Arquivo EBS com nome do arquivo " + fname + " foi recebido com sucesso no SAP @ " +date1+" "+time1;

return "Prezado/a Senhor/a," +" \n " +" \n "+filename;

}

catch(Exception e)

{

String exception = e.toString();

return exception;

}

Por favor, corrija esta UDF.

Obrigada

Neha

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

4 Respuestas

0
Cargando...

Olá Rajesh,

Corrigi o UDF, por favor, teste isso:

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...

Olá Vishnu,

Estou enfrentando um erro com o código abaixo para o carimbo de data e hora:

Preciso do formato de tempo 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...

Olá Neha,

Por favor, teste 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(0, 2);

String mins= time.substring(2, 4);

String secs= time.substring(4, 6);

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

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

String filename= "Arquivo EBS com nome de arquivo " + fname + " foi recebido corretamente no SAP @ " +date1+"† "+time1;

return "Prezado Senhor / Senhora," +" \n " +" \n "+filename;

}

catch(Exception e)

{

String exception = e.toString();

return exception;

}

Apenas corrigi as linhas de substring no seu código.

Saudações

Vishnu

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

Olá Neha,

Corrigi o udf, tente assim:

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= "Arquivo EBS com nome de arquivo " + fname + " foi recebido corretamente no SAP @ " +date1+" "+time1;

return "Prezado/a Senhor/a," +" \n " +" \n "+filename;

}

catch(Exception e)

{

String exception = e.toString();

return exception;

}

Saudações

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?