| | |
| | | @PostConstruct |
| | | void init() { |
| | | // 强制设置默认时区(影响整个JVM) |
| | | TimeZone.setDefault(TimeZone.getTimeZone("Asia/Tokyo")); |
| | | System.setProperty("user.timezone", "Asia/Tokyo"); |
| | | TimeZone.setDefault(TimeZone.getTimeZone("America/New_York")); |
| | | System.setProperty("user.timezone", "America/New_York"); |
| | | } |
| | | |
| | | @Override |
| | |
| | | } |
| | | if(Item.forex.equalsIgnoreCase(bySymbol.getType())){ |
| | | market = new StockMarket(); |
| | | market.setTime_zone( "Asia/Tokyo"); |
| | | market.setTime_zone( "America/New_York"); |
| | | if(MarketOpenChecker.isMarketOpenByItemCloseType(bySymbol.getOpenCloseType())){ |
| | | market.setStatus("交易中"); |
| | | }else{ |
| | |
| | | port: 8235 |
| | | spring: |
| | | datasource: |
| | | # url: jdbc:mysql://127.0.0.1:6306/8.4?allowMultiQueries=true&useSSL=false&useUnicode=true&characterEncoding=UTF-8&autoReconnect=true&zeroDateTimeBehavior=convertToNull&useJDBCCompliantTimezoneShift=true&useLegacyDatetimeCode=false&serverTimezone=GMT%2B8&nullCatalogMeansCurrent=true&serverTimezone=Asia/Tokyo&useLegacyDatetimeCode=false |
| | | url: jdbc:mysql://127.0.0.1:3306/trading_order?allowMultiQueries=true&useSSL=false&useUnicode=true&characterEncoding=UTF-8&autoReconnect=true&zeroDateTimeBehavior=convertToNull&useJDBCCompliantTimezoneShift=true&useLegacyDatetimeCode=false&serverTimezone=GMT%2B8&nullCatalogMeansCurrent=true&serverTimezone=Asia/Tokyo&useLegacyDatetimeCode=false |
| | | # url: jdbc:mysql://127.0.0.1:6306/8.4?allowMultiQueries=true&useSSL=false&useUnicode=true&characterEncoding=UTF-8&autoReconnect=true&zeroDateTimeBehavior=convertToNull&useJDBCCompliantTimezoneShift=true&useLegacyDatetimeCode=false&serverTimezone=GMT%2B8&nullCatalogMeansCurrent=true&serverTimezone=America/New_York&useLegacyDatetimeCode=false |
| | | url: jdbc:mysql://127.0.0.1:3306/trading_order?allowMultiQueries=true&useSSL=false&useUnicode=true&characterEncoding=UTF-8&autoReconnect=true&zeroDateTimeBehavior=convertToNull&useJDBCCompliantTimezoneShift=true&useLegacyDatetimeCode=false&serverTimezone=GMT%2B8&nullCatalogMeansCurrent=true&serverTimezone=America/New_York&useLegacyDatetimeCode=false |
| | | username: trading_order |
| | | password: dzptt5sWi6y6p4Fs |
| | | driver-class-name: com.mysql.cj.jdbc.Driver |
| | |
| | | properties: |
| | | hibernate: |
| | | jdbc: |
| | | time_zone: Asia/Tokyo |
| | | time_zone: America/New_York |
| | | jackson: |
| | | time-zone: Asia/Tokyo |
| | | time-zone: America/New_York |
| | | cache: |
| | | type: redis |
| | | redis: |
| | |
| | | enabled: true |
| | | jackson: |
| | | date-format: yyyy-MM-dd HH:mm:ss |
| | | time-zone: Asia/Tokyo |
| | | time-zone: America/New_York |
| | | mvc: |
| | | pathmatch: |
| | | matching-strategy: ANT_PATH_MATCHER |
| | |
| | | properties: |
| | | hibernate: |
| | | jdbc: |
| | | time_zone: Asia/Tokyo |
| | | time_zone: America/New_York |
| | | # mybaits-plus配置 |
| | | mybatis-plus: |
| | | # MyBatis Mapper所对应的XML文件位置 |
| | |
| | | private String whitepaperUrl; |
| | | |
| | | @ApiModelProperty("申购开始时间") |
| | | @JsonFormat(pattern="yyyy-MM-dd HH:mm:ss",timezone = "Asia/Tokyo") |
| | | @JsonFormat(pattern="yyyy-MM-dd HH:mm:ss",timezone = "America/New_York") |
| | | private Date startDate; |
| | | |
| | | @ApiModelProperty("申购结束时间") |
| | | @JsonFormat(pattern="yyyy-MM-dd HH:mm:ss",timezone = "Asia/Tokyo") |
| | | @JsonFormat(pattern="yyyy-MM-dd HH:mm:ss",timezone = "America/New_York") |
| | | private Date endDate; |
| | | |
| | | @ApiModelProperty("上市开始时间") |
| | | @JsonFormat(pattern="yyyy-MM-dd HH:mm:ss",timezone = "Asia/Tokyo") |
| | | @JsonFormat(pattern="yyyy-MM-dd HH:mm:ss",timezone = "America/New_York") |
| | | private Date marketDate; |
| | | |
| | | @ApiModelProperty("货币图片地址") |
| | |
| | | |
| | | |
| | | @ApiModelProperty("中签时间") |
| | | @JsonFormat(pattern="yyyy-MM-dd HH:mm:ss",timezone = "Asia/Tokyo") |
| | | @JsonFormat(pattern="yyyy-MM-dd HH:mm:ss",timezone = "America/New_York") |
| | | private Date endTime; |
| | | |
| | | @ApiModelProperty("备注") |
| | |
| | | /** |
| | | * 创建日期 |
| | | */ |
| | | @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "Asia/Tokyo") |
| | | @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "America/New_York") |
| | | @TableField(fill = FieldFill.INSERT) |
| | | private Date createTime; |
| | | /** |
| | |
| | | /** |
| | | * 更新日期 |
| | | */ |
| | | @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "Asia/Tokyo") |
| | | @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "America/New_York") |
| | | @TableField(fill = FieldFill.INSERT_UPDATE) |
| | | private Date updateTime; |
| | | |
| | |
| | | |
| | | public static final String DEFAULT_DATE_FORMAT = "yyyy-MM-dd"; |
| | | |
| | | public static final String DEFAULT_TIME_ZONE = "Asia/Tokyo"; |
| | | public static final String DEFAULT_TIME_ZONE = "America/New_York"; |
| | | |
| | | public static final String NORMAL_DATE_FORMAT = "yyyy-MM-dd HH:mm:ss"; |
| | | |
| | |
| | | if (format == null || format.isEmpty()) { |
| | | format = "yyyy-MM-dd HH:mm:ss"; |
| | | } |
| | | TimeZone timeZone = TimeZone.getTimeZone("Asia/Tokyo"); |
| | | TimeZone timeZone = TimeZone.getTimeZone("America/New_York"); |
| | | SimpleDateFormat sdf = new SimpleDateFormat(format); |
| | | sdf.setTimeZone(timeZone); |
| | | // 类库使用时候,也保证有个正确结果 |
| | |
| | | if (millisecond == null || millisecond.isEmpty() || millisecond.equals("null")) { |
| | | return ""; |
| | | } |
| | | TimeZone timeZone = TimeZone.getTimeZone("Asia/Tokyo"); |
| | | TimeZone timeZone = TimeZone.getTimeZone("America/New_York"); |
| | | SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); |
| | | sdf.setTimeZone(timeZone); |
| | | return sdf.format(new Date(Long.valueOf(millisecond))); |
| | |
| | | // 1. 确定时间戳单位(假设ts是毫秒级,若为秒级需用ofEpochSecond()) |
| | | Instant instant = Instant.ofEpochMilli(ts); |
| | | |
| | | // 2. 将时间戳转换为当地时区的日期(指定时区更准确,如Asia/Tokyo) |
| | | LocalDate tsDate = instant.atZone(ZoneId.of("Asia/Tokyo")).toLocalDate(); |
| | | // 2. 将时间戳转换为当地时区的日期(指定时区更准确,如America/New_York) |
| | | LocalDate tsDate = instant.atZone(ZoneId.of("America/New_York")).toLocalDate(); |
| | | |
| | | // 3. 获取“昨天的日期”(当前日期减1天) |
| | | LocalDate yesterday = LocalDate.now(ZoneId.of("Asia/Tokyo")).minusDays(1); |
| | | LocalDate yesterday = LocalDate.now(ZoneId.of("America/New_York")).minusDays(1); |
| | | |
| | | // 4. 判断是否为昨天 |
| | | boolean isYesterday = tsDate.equals(yesterday); |
| | |
| | | long currentTimeStamp = System.currentTimeMillis(); |
| | | |
| | | // 如果需要严格基于东京时区的当前时间戳(结果和上面一致,因为时间戳是UTC绝对时间) |
| | | //long currentTokyoTimeStamp = Instant.now().atZone(ZoneId.of("Asia/Tokyo")).toInstant().toEpochMilli(); |
| | | //long currentTokyoTimeStamp = Instant.now().atZone(ZoneId.of("America/New_York")).toInstant().toEpochMilli(); |
| | | RequestDataHelper.set("symbol", symbol); |
| | | QueryWrapper<Realtime> queryWrapper = new QueryWrapper<Realtime>() |
| | | .eq("symbol", symbol) // 直接写数据库字段名(需和表字段一致) |