on 02-05-2007 3:09 PM
Hello,
In SAP XI java mapping I write the code above,
At the moment I received the file name "<b>ABC.0050673686_2007025</b>"
I want to receive file name like that "<b>ABC.0050673686_20070205</b>"
I want to change date from yyyymmd to yyyymmdd
"
public String Change(String a,String Order_Num,Container container){
//Get the Date
Date Today = new java.sql.Date(new java.util.Date().getTime());
//Construct File Name = Macon.Order_NumYearMonthDay
long nowyear = 1900 + Today.getYear();
long nowmonth = 1 + Today.getMonth();
long nowdate = Today.getDate();
String RecieverFilename = "ABC."+ Order_Num +"_" + nowyearnowmonthnowdate;
//Set XI Runtime Parameters
DynamicConfiguration conf = (DynamicConfiguration) container.getTransformationParameters().get(StreamTransformationConstants.DYNAMIC_CONFIGURATION);
DynamicConfigurationKey key = DynamicConfigurationKey.create("http:" + "/" + "/" + "sap.com/xi/XI/System/File", "FileName");
conf.put(key, RecieverFilename);
return a;
"
Any idea?
Regards
Elad
Hi Elad,
The dateformat can be changed using SimpleDateFormat class from java API.
Incude the below code:
import java.text.SimpleDateFormat;
import java.util.Date;
SimpleDateFormat df= new SimpleDateFormat("yyyymmdd");
changedDate = df.format( new Date(date));
Thanks,
Swathi
please offer points if it was useful:-)
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Elad,
To change the date format as per ur reqrmnt, do the following
import java.text.*;
SimpleDateFormat sdf=new SimpleDateFormat("yyyymmdd");
String formatteddate=sdf.format(new Date());//FOR util date
String formatteddate=sdf.format(new Date(System.currentTimeMillis()));//FOR sql date
Regards
Fahad Hamsa
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Consider using java.text.DateFormat / java.text.SimpleDateFormat classes for date format conversions.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
86 | |
10 | |
10 | |
9 | |
6 | |
6 | |
6 | |
5 | |
4 | |
3 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.