kunal642 commented on a change in pull request #3970:
URL: https://github.com/apache/carbondata/pull/3970#discussion_r508306255



##########
File path: 
sdk/sdk/src/main/java/org/apache/carbondata/sdk/file/CarbonReader.java
##########
@@ -109,7 +116,39 @@ public boolean hasNext() throws IOException, 
InterruptedException {
    */
   public T readNextRow() throws IOException, InterruptedException {
     validateReader();
-    return currentReader.getCurrentValue();
+    return formatDateAndTimeStamp((Object[]) currentReader.getCurrentValue());
+  }
+
+  public T formatDateAndTimeStamp(Object[] row) {
+    List<ProjectionDimension> dimensions = ((AbstractRecordReader) 
currentReader)
+            .getQueryModel().getProjectionDimensions();
+    String carbonDateFormat = CarbonProperties.getInstance()
+            .getProperty(CarbonCommonConstants.CARBON_DATE_FORMAT);
+    if (carbonDateFormat == null) {
+      carbonDateFormat = CarbonCommonConstants.CARBON_DATE_DEFAULT_FORMAT;
+    }
+    SimpleDateFormat dateFormat = new SimpleDateFormat(carbonDateFormat);
+    String carbonTimeStampFormat = CarbonProperties.getInstance()
+            .getProperty(CarbonCommonConstants.CARBON_TIMESTAMP_FORMAT);
+    if (carbonTimeStampFormat  == null) {
+      carbonTimeStampFormat  = 
CarbonCommonConstants.CARBON_TIMESTAMP_DEFAULT_FORMAT;
+    }
+    SimpleDateFormat timeStampFormat = new 
SimpleDateFormat(carbonTimeStampFormat);
+    for (ProjectionDimension dimension : dimensions) {
+      ColumnSchema columnSchema = dimension.getDimension().getColumnSchema();
+      if (columnSchema == null) {
+        continue;
+      }
+      DataType dataType = columnSchema.getDataType();
+      if (dataType == DataTypes.DATE) {
+        row[dimension.getOrdinal()] = dateFormat
+                .format(new Date(24L * 3600 * 1000 * 
(int)row[dimension.getOrdinal()]));

Review comment:
       use DateDirectDictionaryGenerator.MILLIS_PER_DAY instead of "24L * 3600 
* 1000 *"




----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


Reply via email to