[ 
https://issues.apache.org/jira/browse/FLINK-19757?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17218759#comment-17218759
 ] 

xiaogang zhou commented on FLINK-19757:
---------------------------------------

[~jark] thx for commenting, if i run the sql 

tEnv.executeSql("CREATE TABLE Source (\n" +
 " -- declare the schema of the table\n" +
 " `name` STRING,\n" +
 " `num` INT,\n" +
 " `xtime` as proctime()\n"+
 ") WITH (\n" +
 " -- declare the external system to connect to\n" +
 " 'connector' = 'bsql-datagen',\n" +
 " 'rows-per-second' = '1'\n" +
 ")");

 

if i call the stream.print() , i will get a time 8 hrs ago(as my default time 
zone is +8). how can i fix this problem?

 

furthermore, if i print 

Timestamp ts = new Timestamp(System.currentTimeMillis());

System.err.println(TimestampData.fromTimestamp(ts));    
//2020-10-22T13:40:28.596
System.err.println(TimestampData.fromEpochMillis(System.currentTimeMillis()));  
 //2020-10-22T05:40:28.724

 

this is pretty strange, can you please suggest in which way i can get the 
correct time?

thx for your time

 

 

> TimeStampData can cause time inconsistent problem
> -------------------------------------------------
>
>                 Key: FLINK-19757
>                 URL: https://issues.apache.org/jira/browse/FLINK-19757
>             Project: Flink
>          Issue Type: Improvement
>          Components: Table SQL / Runtime
>    Affects Versions: 1.11.1
>            Reporter: xiaogang zhou
>            Priority: Major
>              Labels: pull-request-available
>
> when we check jdk LocalDateTime code,we find that
>  
> {code:java}
> // code placeholder
> public static LocalDateTime ofEpochSecond(long epochSecond, int nanoOfSecond, 
> ZoneOffset offset) {
>     Objects.requireNonNull(offset, "offset");
>     NANO_OF_SECOND.checkValidValue(nanoOfSecond);
>     long localSecond = epochSecond + offset.getTotalSeconds();  // overflow 
> caught later
>     long localEpochDay = Math.floorDiv(localSecond, SECONDS_PER_DAY);
>     int secsOfDay = (int)Math.floorMod(localSecond, SECONDS_PER_DAY);
>     LocalDate date = LocalDate.ofEpochDay(localEpochDay);
>     LocalTime time = LocalTime.ofNanoOfDay(secsOfDay * NANOS_PER_SECOND + 
> nanoOfSecond);
>     return new LocalDateTime(date, time);
> }
> {code}
>  
> offset.getTotalSeconds() they add the offset, but in the TimeStampData
> toLocalDateTime, we don't add a offset.
>  
> I'd like to add a TimeZone.getDefault().getRawOffset() in the 
> toLocalDateTime()
> and minus a TimeZone.getDefault().getRawOffset() in the 
> fromLocalDateTime



--
This message was sent by Atlassian Jira
(v8.3.4#803005)

Reply via email to