How to change code from tjava to globalmap.put variable

Highlighted
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
Sixteen Stars
Sixteen 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 GARTNER 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

Best Practices for Using Context Variables with Talend – Part 2

Part 2 of a series on Context Variables

Blog

Best Practices for Using Context Variables with Talend – Part 1

Learn how to do cool things with Context Variables

Blog

Migrate Data from one Database to another with one Job using the Dynamic Schema

Find out how to migrate from one database to another using the Dynamic schema

Blog