How to change code from tjava to globalmap.put variable

Six Stars

How to change code from tjava to globalmap.put variable

Hi,

i want to use the below java code into globalmap.put variable. so that i can use those values as parameters like  '" + ((String)globalMap.get("xxxx"))+"' 

below is the code .

Date lastDec =TalendDate.parseDate("yyyy-MM-dd", TalendDate.getDate("yyyy-MM-dd"));
System.out.println("param1: "+TalendDate.TO_CHAR(lastDec, "MMM-yy"));

 

Date prevYear1 = TalendDate.ADD_TO_DATE(lastDec, "YYYY", -1);
System.out.println("param3: "+TalendDate.TO_CHAR(prevYear1, "MMM-yy"));

 

Date prevYear = TalendDate.ADD_TO_DATE(lastDec, "MM", -3);
System.out.println("param2: "+TalendDate.TO_CHAR(prevYear, "MMM-yy"));

 

example i need like this.

 

globalMap.put("lastDec",
TalendDate.TO_CHAR(TalendDate.ADD_TO_DATE(
TalendDate.setDate(TalendDate.getCurrentDate(), 12, "MM"), "YYYY", -1), "MMM-yy"));

Highlighted
Fifteen Stars TRF
Fifteen Stars

Re: How to change code from tjava to globalmap.put variable

Here it is:

globalMap.put("lastDec", TalendDate.ADD_TO_DATE(TalendDate.setDate(TalendDate.getCurrentDate(), 12, "MM"), "YYYY", -1));
System.out.println("lastDec: "+TalendDate.TO_CHAR((Date)globalMap.get("lastDec"), "yyyyMM"));

globalMap.put("prevYear1", TalendDate.ADD_TO_DATE((Date)globalMap.get("lastDec"), "YYYY", -1));
System.out.println("prevYear1: "+TalendDate.TO_CHAR((Date)globalMap.get("prevYear1"), "MMM-yy"));

globalMap.put("prevYear", TalendDate.ADD_TO_DATE((Date)globalMap.get("lastDec"), "MM", -3));
System.out.println("prevYear: "+TalendDate.TO_CHAR((Date)globalMap.get("prevYear"), "MMM-yy"));

TRF

2019 GARNER MAGIC QUADRANT FOR DATA INTEGRATION TOOL

Talend named a Leader.

Get your copy

OPEN STUDIO FOR DATA INTEGRATION

Kickstart your first data integration and ETL projects.

Download now

What’s New for Talend Summer ’19

Watch the recorded webinar!

Watch Now

Best Practices for Using Context Variables with Talend – Part 4

Pick up some tips and tricks with Context Variables

Blog

How Media Organizations Achieved Success with Data Integration

Learn how media organizations have achieved success with Data Integration

Read

Agile Data lakes & Analytics

Accelerate your data lake projects with an agile approach

Watch