Example: Getting and Setting the Time Zone in a Java Table Operator - Analytics Database - Teradata Vantage

SQL External Routine Programming

Deployment
VantageCloud
VantageCore
Edition
Enterprise
IntelliFlex
VMware
Product
Analytics Database
Teradata Vantage
Release Number
17.20
Published
June 2022
ft:locale
en-US
ft:lastEdition
2025-03-30
dita:mapPath
iiv1628111441820.ditamap
dita:ditavalPath
qkf1628213546010.ditaval
dita:id
qnu1472247494689
lifecycle
latest
Product Category
Teradata Vantageā„¢

The following code excerpt shows the usage of the Java TeradataTime and TeradataTimestamp data types and the getTimeZone and setTimeZone methods for getting and setting the time zone value in a Java table operator.

String timezone = "America/New_York";
Calendar c = Calendar.getInstance();
TimeZone tz = TimeZone.getTimeZone(timezone);
c.setTimeZone(tz);

TeradataTimestamp tts = new TeradataTimestamp( c.getTimeInMillis());
tts.setTimeZone(tz);

TeradataTime tTime = new TeradataTime(c.getTimeInMillis());
tTime.setTimeZone(tz);

   if(outObjs[i] instanceof TeradataTimestamp){
      TeradataTimestamp outtts = (TeradataTimestamp)outObjs[i];
      java.util.TimeZone tz = outtts.getTimeZone();
   }
   else if(outObjs[i] instanceof TeradataTime){
      TeradataTime outtTime = (TeradataTime)outObjs[i];
      java.util.TimeZone tz = outtTime.getTimeZone();
   }
   else if(outObjs[i] instanceof Time){
      Time outtTime = (Time)outObjs[i];
      printSimpleTimeReading(outtTime);
   }
   else if(outObjs[i] instanceof Timestamp){
      Timestamp outtTime = (Timestamp)outObjs[i];
      printSimpleTimestampReading(outtTime);
   }