on 12-23-2011 12:38 AM
Hi java gurus,
Can someone write below abap code into UDF.
This is to convert julian date(2011348) to calendar date(12/13/2011)
-
ABAP code for Julian date conversion
_________________________________________
DATA: jdate(7) VALUE '2011348',
gdate TYPE sy-datum,
days TYPE i.
CONCATENATE jdate(4) '0101' INTO gdate.
days = jdate+4(3).
gdate = gdate + days.
____________________________________________
ty.
Hi,
You can try with standard date function "TransformDate".
In the function set parameters as below
please use format of source date as: yyyyD
and target format as : MM/dd/yyyy
I feel there is no need of an UDF.
Regards
Anupam
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Thanks guys.
it worked well with standard function.
also, another UDF for future references on this post,
Calendar calendar = Calendar.getInstance();
calendar.set(Calendar.YEAR, Integer.parseInt(Integer.toString(calendar.get(Calendar.YEAR)).substring(0, 2)+inpdate.substring(0, 2)));
calendar.set(Calendar.DAY_OF_YEAR, Integer.parseInt(inpdate.substring(inpdate.length() - 3, inpdate.length())));
SimpleDateFormat simpDate = new SimpleDateFormat("ddMMyy");
return simpDate.format(calendar.getTime());
Hi. Santosh
Tyr this simple UDF.
String val = "2011348";
Date myDate = new SimpleDateFormat("yyyyD").parse(val);
SimpleDateFormat sdf= new java.text.SimpleDateFormat("MM/dd/yyyy");
String fecha = sdf.format(myDate);
return fecha;
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi. Try this
Don't forget to add the reference.
import java.util.Date;
import java.text.SimpleDateFormat;
String fecha ="";
try {
String val = "2011348";
Date myDate = new SimpleDateFormat("yyyyD").parse(val);
SimpleDateFormat sdf= new java.text.SimpleDateFormat("MM/dd/yyyy");
fecha = sdf.format(myDate);
} catch (Exception ex) {
ex.printStackTrace();
}
return fecha;
User | Count |
---|---|
86 | |
10 | |
10 | |
9 | |
7 | |
7 | |
6 | |
5 | |
4 | |
4 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.