/** * 取得季度第一天. * * @param date 日期 * @return 传入的日期当季的开始日期 */ public static LocalDate getSeasonStart(final LocalDate date) { return getSeasonDate(date)[0]; }
/** * 判断开始时间和结束时间,是否超出了当前时间的一定的间隔数限制 如:开始时间和结束时间,不能超出距离当前时间90天. * * @param startDate 开始时间 * @param endDate 结束时间按 * @param interval 间隔数 * @return true or false */ public static boolean isOverIntervalLimit(final LocalDate startDate, final LocalDate endDate, final int interval) { return getDaysBetween(startDate, endDate) >= interval; }
/** * Random uuid long. * * @return the long */ public long randomUUID() { return ID_WORKER_UTILS.nextId(); } }
@Override public void init(final String appName, final TxConfig txConfig) { keyName = RepositoryPathUtils.buildRedisKey(appName); final TxRedisConfig txRedisConfig = txConfig.getTxRedisConfig(); try { buildJedisClient(txRedisConfig); } catch (Exception e) { LogUtil.error(LOGGER, "redis init exception please check your config :{}", e::getMessage); } }
@Override public void init(final String appName, final TxConfig txConfig) { setRootPath(RepositoryPathUtils.buildZookeeperPath(appName)); try { connect(txConfig.getTxZookeeperConfig()); } catch (Exception e) { LogUtil.error(LOGGER, "zookeeper init exception please check you config:{}", e::getMessage); throw new TransactionRuntimeException(e.getMessage()); } }
@Override public Boolean login(final String userName, final String password) { LogUtil.info(LOGGER, "输入的用户名密码为:{}", () -> userName + "," + password); if (userName.equals(this.userName) && password.equals(this.password)) { LOGIN_SUCCESS = true; return Boolean.TRUE; } return Boolean.FALSE; }
public void setDbType(final String dbType) { this.dbType = DbTypeUtils.buildByDriverClassName(dbType); }
@Override public void init(final String appName, final TxConfig txConfig) { filePath = RepositoryPathUtils.buildFilePath(appName); File file = new File(filePath); if (!file.exists()) { file.getParentFile().mkdirs(); file.mkdirs(); } }
/** * 根据日期字符串获取时间戳. * * @param dateStr yyyy-MM-dd HH:mm:ss * @return 时间信息 * @throws ParseException 异常 */ public static Instant parseDataStrToInstant(final String dateStr) throws ParseException { return parseLocalDateTime(dateStr).toInstant(ZoneOffset.UTC); }
public static byte[] getRedisKey(String keyPrefix, String id) { return RedisKeyUtils.getRedisKey(keyPrefix, id); }
private String buildBannerText() { return CommonConstant.LINE_SEPARATOR + CommonConstant.LINE_SEPARATOR + HMILY_LOGO + CommonConstant.LINE_SEPARATOR + " :: raincat :: (v" + VersionUtils.getVersion(getClass(), "1.0.0") + ")" + CommonConstant.LINE_SEPARATOR; }
/** * 获取昨天的日期 格式串:yyyy-MM-dd. * * @return yyyy-MM-dd */ public static String getYesterday() { return getYesterday(LocalDate.now()); }
/** * 将数据库时间改成当前时区时间. * @param timestamp 时间 * @return time * @date 2018/5/9 18:25 */ public static LocalDateTime toDefaultDateTime(final Timestamp timestamp) { return timestamp == null ? null : toDefaultDateTime(timestamp.toLocalDateTime()); }
public void rollBack(final List<TxTransactionItem> txTransactionItems) { try { execute(txTransactionItems, TransactionStatusEnum.ROLLBACK); } catch (Exception e) { e.printStackTrace(); LogUtil.info(LOGGER, "txManger 发送rollback指令异常 ", e::getMessage); } }
/** * Build part number string. * * @return the string */ public String buildPartNumber() { return "P" + ID_WORKER_UTILS.nextId(); }
/** * 取得季度最后一天. * * @param date 日期 * @return 传入的日期当季的结束日期 */ public static LocalDate getSeasonEnd(final LocalDate date) { return getSeasonDate(date)[2].with(TemporalAdjusters.lastDayOfMonth()); }
/** * Create task key string. * * @return the string */ public String createTaskKey() { return String.valueOf(ID_WORKER_UTILS.nextId()); }
/** * Create group id string. * * @return the string */ public String createGroupId() { return String.valueOf(ID_WORKER_UTILS.nextId()); }
/** * Create uuid string. * * @return the string */ public String createUUID() { return String.valueOf(ID_WORKER_UTILS.nextId()); }