<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: Calendar cannot be resolved to a type in Talend Studio</title>
    <link>https://community.qlik.com/t5/Talend-Studio/Calendar-cannot-be-resolved-to-a-type/m-p/2363505#M127376</link>
    <description>&lt;P&gt;That is a lot of code to format a date. This works and is a little less work....&lt;/P&gt;
&lt;PRE&gt;String source = "2017-05-12T10:15:22+02:00";
source = source.substring(0, source.lastIndexOf(':'))+source.substring(source.lastIndexOf(':')+1);
System.out.println(source);
Date now = routines.TalendDate.parseDateInUTC("yyyy-MM-dd'T'HH:mm:ssZ", source, true);
System.out.println(routines.TalendDate.formatDateInUTC("dd/MM/yyyy HH:mm:ss", now));&lt;/PRE&gt;
&lt;P&gt;The +02:00 causes an issue as it should be +0200 without the ":". Remove this and the code you need is already provided by Talend.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Your code is causing the error this post is about due to this line....&lt;/P&gt;
&lt;PRE&gt;Calendar cal = new GregorianCalendar();&lt;/PRE&gt;
&lt;P&gt;You can fix it with this....&lt;/P&gt;
&lt;PRE&gt;java.util.Calendar cal = new java.util.GregorianCalendar();&lt;/PRE&gt;
&lt;P&gt;....but I suspect you will get more errors regarding HashMap, Map, Set, etc...&lt;/P&gt;</description>
    <pubDate>Thu, 15 Feb 2018 12:11:25 GMT</pubDate>
    <dc:creator>Anonymous</dc:creator>
    <dc:date>2018-02-15T12:11:25Z</dc:date>
    <item>
      <title>Calendar cannot be resolved to a type</title>
      <link>https://community.qlik.com/t5/Talend-Studio/Calendar-cannot-be-resolved-to-a-type/m-p/2363504#M127375</link>
      <description>&lt;P&gt;Hi&lt;/P&gt;
&lt;P&gt;I try to convert a date with timezone information into a simple date UTC.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The source Date for example is:&amp;nbsp;"2017-05-12T10:15:22+02:00"&lt;/P&gt;
&lt;P&gt;The target date with subtraction of the time zone information would be "12/05/2017 08:15:22"&lt;/P&gt;
&lt;P&gt;It works already for one of may jobs but unfortunately not for the others.&lt;/P&gt;
&lt;P&gt;I also wonder if there is a simpler way.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The error message is:&lt;/P&gt;
&lt;P&gt;- Calendar cannot be resolved to a type&lt;BR /&gt;- GregorianCalendar cannot be resolved to a type&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The code is:&lt;/P&gt;
&lt;PRE&gt;// declare and init variables and data structures
String datetime = "";
String d = "";
String t = ""; 
String add = "";
String year = ""; 
String month = ""; 
String day = ""; 
String finDate = "";
int a; 
Date myDateTime = null;
String myString = ""; 
SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm");
Calendar cal = new GregorianCalendar();
HashMap&amp;lt;String, String&amp;gt; hm = new HashMap&amp;lt;String, String&amp;gt;();


// put values in hash map
hm.put("NUMStartDate", input_row._NUMStartDate_);
hm.put("NUMEndDate", input_row._NUMEndDate_);
hm.put("PublicationTimeStamp", input_row._PublicationTimeStamp_);
hm.put("ModificationTimeStamp", input_row._ModificationTimeStamp_);
hm.put("TimeStamp", input_row._TimeStamp_);

// iterate over values in hash map and extract date and time
Set set = hm.entrySet();
Iterator iterator = set.iterator();
while(iterator.hasNext()){
 	Map.Entry mentry = (Map.Entry)iterator.next();
	datetime = mentry.getValue() + "";
   switch (datetime) { 
      	case "null": 
      		datetime = "9999-01-01T00:00:00+00:00";
      	}
      d = datetime.substring(0, 10) + "";
      t = datetime.substring(11, datetime.length()-9);
      add = datetime.substring(19, datetime.length()-3);
      a = Integer.parseInt(add);
      myString =  d + " " + t;
      try
      {
            myDateTime = simpleDateFormat.parse(myString);
      }
      catch (ParseException e)
      {
            e.printStackTrace();
      }
      cal.setTime(myDateTime);
      // subtract hours to date
      cal.add(Calendar.HOUR_OF_DAY, - a);
      Date date = cal.getTime();

      datetime = simpleDateFormat.format( date );
      d = datetime.substring(0, 10) + "";
      t = datetime.substring(11, datetime.length());
      year = datetime.substring(0, 4);
	  month = datetime.substring(5, 7);
	  day = datetime.substring(8, 10);

    finDate =  day + "/" + month + "/" + year + " " + t;

    //System.out.println("Key: " + mentry.getKey() + " " + finDate + "");

		switch (mentry.getKey() + "") {
      	case "NUMStartDate":
      		output_row._NUMStartDate_ = finDate;
      	case "NUMEndDate":
      		output_row._NUMEndDate_ = finDate;
      	case "PublicationTimeStamp":
      		output_row._PublicationTimeStamp_ = finDate;
      	case "ModificationTimeStamp":
      		output_row._ModificationTimeStamp_ = finDate;
      	case "TimeStamp":
      		output_row._TimeStamp_ = finDate;
      	      		
    }

}&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 15 Feb 2018 11:20:40 GMT</pubDate>
      <guid>https://community.qlik.com/t5/Talend-Studio/Calendar-cannot-be-resolved-to-a-type/m-p/2363504#M127375</guid>
      <dc:creator>misch</dc:creator>
      <dc:date>2018-02-15T11:20:40Z</dc:date>
    </item>
    <item>
      <title>Re: Calendar cannot be resolved to a type</title>
      <link>https://community.qlik.com/t5/Talend-Studio/Calendar-cannot-be-resolved-to-a-type/m-p/2363505#M127376</link>
      <description>&lt;P&gt;That is a lot of code to format a date. This works and is a little less work....&lt;/P&gt;
&lt;PRE&gt;String source = "2017-05-12T10:15:22+02:00";
source = source.substring(0, source.lastIndexOf(':'))+source.substring(source.lastIndexOf(':')+1);
System.out.println(source);
Date now = routines.TalendDate.parseDateInUTC("yyyy-MM-dd'T'HH:mm:ssZ", source, true);
System.out.println(routines.TalendDate.formatDateInUTC("dd/MM/yyyy HH:mm:ss", now));&lt;/PRE&gt;
&lt;P&gt;The +02:00 causes an issue as it should be +0200 without the ":". Remove this and the code you need is already provided by Talend.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Your code is causing the error this post is about due to this line....&lt;/P&gt;
&lt;PRE&gt;Calendar cal = new GregorianCalendar();&lt;/PRE&gt;
&lt;P&gt;You can fix it with this....&lt;/P&gt;
&lt;PRE&gt;java.util.Calendar cal = new java.util.GregorianCalendar();&lt;/PRE&gt;
&lt;P&gt;....but I suspect you will get more errors regarding HashMap, Map, Set, etc...&lt;/P&gt;</description>
      <pubDate>Thu, 15 Feb 2018 12:11:25 GMT</pubDate>
      <guid>https://community.qlik.com/t5/Talend-Studio/Calendar-cannot-be-resolved-to-a-type/m-p/2363505#M127376</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2018-02-15T12:11:25Z</dc:date>
    </item>
    <item>
      <title>Re: Calendar cannot be resolved to a type</title>
      <link>https://community.qlik.com/t5/Talend-Studio/Calendar-cannot-be-resolved-to-a-type/m-p/2363506#M127377</link>
      <description>&lt;P&gt;Great, thanks for your quick answer, it works.&lt;/P&gt;</description>
      <pubDate>Thu, 15 Feb 2018 12:38:51 GMT</pubDate>
      <guid>https://community.qlik.com/t5/Talend-Studio/Calendar-cannot-be-resolved-to-a-type/m-p/2363506#M127377</guid>
      <dc:creator>misch</dc:creator>
      <dc:date>2018-02-15T12:38:51Z</dc:date>
    </item>
  </channel>
</rss>

