| | |
| | | @PostConstruct |
| | | void init() { |
| | | // 强制设置默认时区(影响整个JVM) |
| | | TimeZone.setDefault(TimeZone.getTimeZone("Asia/Shanghai")); |
| | | System.setProperty("user.timezone", "Asia/Shanghai"); |
| | | TimeZone.setDefault(TimeZone.getTimeZone("Asia/Tokyo")); |
| | | System.setProperty("user.timezone", "Asia/Tokyo"); |
| | | } |
| | | |
| | | @Override |
| | |
| | | } |
| | | if(Item.forex.equalsIgnoreCase(bySymbol.getType())){ |
| | | market = new StockMarket(); |
| | | market.setTime_zone( "Asia/Shanghai"); |
| | | market.setTime_zone( "Asia/Tokyo"); |
| | | 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/Shanghai&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/Shanghai&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=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 |
| | | username: root |
| | | password: REbZZEBRfGect48X |
| | | driver-class-name: com.mysql.cj.jdbc.Driver |
| | |
| | | properties: |
| | | hibernate: |
| | | jdbc: |
| | | time_zone: Asia/Shanghai |
| | | time_zone: Asia/Tokyo |
| | | jackson: |
| | | time-zone: Asia/Shanghai |
| | | time-zone: Asia/Tokyo |
| | | cache: |
| | | type: redis |
| | | redis: |
| | |
| | | enabled: true |
| | | jackson: |
| | | date-format: yyyy-MM-dd HH:mm:ss |
| | | time-zone: Asia/Shanghai |
| | | time-zone: Asia/Tokyo |
| | | mvc: |
| | | pathmatch: |
| | | matching-strategy: ANT_PATH_MATCHER |
| | |
| | | properties: |
| | | hibernate: |
| | | jdbc: |
| | | time_zone: Asia/Shanghai |
| | | time_zone: Asia/Tokyo |
| | | # mybaits-plus配置 |
| | | mybatis-plus: |
| | | # MyBatis Mapper所对应的XML文件位置 |
| | |
| | | private String whitepaperUrl; |
| | | |
| | | @ApiModelProperty("申购开始时间") |
| | | @JsonFormat(pattern="yyyy-MM-dd HH:mm:ss",timezone = "Asia/Shanghai") |
| | | @JsonFormat(pattern="yyyy-MM-dd HH:mm:ss",timezone = "Asia/Tokyo") |
| | | private Date startDate; |
| | | |
| | | @ApiModelProperty("申购结束时间") |
| | | @JsonFormat(pattern="yyyy-MM-dd HH:mm:ss",timezone = "Asia/Shanghai") |
| | | @JsonFormat(pattern="yyyy-MM-dd HH:mm:ss",timezone = "Asia/Tokyo") |
| | | private Date endDate; |
| | | |
| | | @ApiModelProperty("上市开始时间") |
| | | @JsonFormat(pattern="yyyy-MM-dd HH:mm:ss",timezone = "Asia/Shanghai") |
| | | @JsonFormat(pattern="yyyy-MM-dd HH:mm:ss",timezone = "Asia/Tokyo") |
| | | private Date marketDate; |
| | | |
| | | @ApiModelProperty("货币图片地址") |
| | |
| | | |
| | | |
| | | @ApiModelProperty("中签时间") |
| | | @JsonFormat(pattern="yyyy-MM-dd HH:mm:ss",timezone = "Asia/Shanghai") |
| | | @JsonFormat(pattern="yyyy-MM-dd HH:mm:ss",timezone = "Asia/Tokyo") |
| | | private Date endTime; |
| | | |
| | | @ApiModelProperty("备注") |
| | |
| | | /** |
| | | * 创建日期 |
| | | */ |
| | | @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "Asia/Shanghai") |
| | | @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "Asia/Tokyo") |
| | | @TableField(fill = FieldFill.INSERT) |
| | | private Date createTime; |
| | | /** |
| | |
| | | /** |
| | | * 更新日期 |
| | | */ |
| | | @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "Asia/Shanghai") |
| | | @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "Asia/Tokyo") |
| | | @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/Shanghai"; |
| | | public static final String DEFAULT_TIME_ZONE = "Asia/Tokyo"; |
| | | |
| | | 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/Shanghai"); |
| | | TimeZone timeZone = TimeZone.getTimeZone("Asia/Tokyo"); |
| | | SimpleDateFormat sdf = new SimpleDateFormat(format); |
| | | sdf.setTimeZone(timeZone); |
| | | // 类库使用时候,也保证有个正确结果 |
| | |
| | | if (millisecond == null || millisecond.isEmpty() || millisecond.equals("null")) { |
| | | return ""; |
| | | } |
| | | TimeZone timeZone = TimeZone.getTimeZone("Asia/Shanghai"); |
| | | TimeZone timeZone = TimeZone.getTimeZone("Asia/Tokyo"); |
| | | SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); |
| | | sdf.setTimeZone(timeZone); |
| | | return sdf.format(new Date(Long.valueOf(millisecond))); |
| | |
| | | public static List<OpenCloseTime> listAOpenCloseDateTime(){ |
| | | int year = 2023; |
| | | List<OpenCloseTime> times = Lists.newArrayList(); |
| | | ZoneId nyseZone = ZoneId.of("Asia/Shanghai"); // 纽约时区 |
| | | ZoneId nyseZone = ZoneId.of("America/New_York"); // 纽约时区 |
| | | ZoneId beijingZone = ZoneId.of("Asia/Shanghai"); // 北京时区 |
| | | |
| | | LocalDateTime startDate = LocalDateTime.of(year, 1, 1, 0, 0); |
| | |
| | | // 1. 确定时间戳单位(假设ts是毫秒级,若为秒级需用ofEpochSecond()) |
| | | Instant instant = Instant.ofEpochMilli(ts); |
| | | |
| | | // 2. 将时间戳转换为当地时区的日期(指定时区更准确,如Asia/Shanghai) |
| | | LocalDate tsDate = instant.atZone(ZoneId.of("Asia/Shanghai")).toLocalDate(); |
| | | // 2. 将时间戳转换为当地时区的日期(指定时区更准确,如Asia/Tokyo) |
| | | LocalDate tsDate = instant.atZone(ZoneId.of("Asia/Tokyo")).toLocalDate(); |
| | | |
| | | // 3. 获取“昨天的日期”(当前日期减1天) |
| | | LocalDate yesterday = LocalDate.now(ZoneId.of("Asia/Shanghai")).minusDays(1); |
| | | LocalDate yesterday = LocalDate.now(ZoneId.of("Asia/Tokyo")).minusDays(1); |
| | | |
| | | // 4. 判断是否为昨天 |
| | | boolean isYesterday = tsDate.equals(yesterday); |