java 请求参数 加签名_Java HTTP POST请求,接口参数加签,验签的操作方法

这个博客详细介绍了如何在Java中处理HTTP POST请求时进行参数加签和验签的操作,提供了相关日期处理工具类DateUtils,包含获取日期范围、格式化日期等方法。
摘要由CSDN通过智能技术生成

importorg.apache.commons.lang3.StringUtils;importorg.apache.commons.lang3.time.FastDateFormat;importorg.slf4j.Logger;importorg.slf4j.LoggerFactory;importjava.lang.management.ManagementFactory;importjava.text.ParseException;importjava.text.ParsePosition;importjava.text.SimpleDateFormat;importjava.util.Calendar;importjava.util.Date;/*** 日期处理*/

public class DateUtils extendsorg.apache.commons.lang3.time.DateUtils {private final static Logger logger = LoggerFactory.getLogger(DateUtils.class);private static String[] parsePatterns = { "yyyy-MM-dd", "yyyy-MM-dd HH:mm:ss", "yyyy-MM-dd HH:mm", "yyyy-MM-dd HH","yyyy-MM", "yyyy/MM/dd", "yyyy/MM/dd HH:mm:ss", "yyyy/MM/dd HH:mm", "yyyy/MM/dd HH", "yyyy/MM","yyyy.MM.dd", "yyyy.MM.dd HH:mm:ss", "yyyy.MM.dd HH:mm", "yyyy.MM.dd HH", "yyyy.MM", "yyyy年MM月dd日","yyyy年MM月dd日 HH时mm分ss秒", "yyyy年MM月dd日 HH时mm分", "yyyy年MM月dd日 HH时", "yyyy年MM月", "yyyy"};/*** 获取

* 从今天往前beforeDay天到明天凌晨的时间范围,集合范围: [开始时间, 结束时间)

*@return

*/

public static Date[] getTodayDateRange(intbeforeDay) {

Date startDate= DateUtils.truncate(newDate(), Calendar.DATE);

Date endDate= DateUtils.addDays(startDate, 1);if (beforeDay > 0) {

startDate= DateUtils.addDays(startDate, -beforeDay);

}return newDate[] {startDate, endDate};

}/*** 获取

* 从今天往前beforeDay天到明天凌晨的时间范围,集合范围: [开始时间, 结束时间)

*@return

*/

public static String[] getTodayDateRangeStr(intbeforeDay) {

Date startDate= DateUtils.truncate(newDate(), Calendar.DATE);

Date endDate= DateUtils.addDays(startDate, 1);if (beforeDay > 0) {

startDate= DateUtils.addDays(startDate, -beforeDay);

}

String startDateStr= formatDate(startDate, parsePatterns[1]);

String endDateStr= formatDate(endDate, parsePatterns[1]);return newString[] {startDateStr, endDateStr};

}/*** 获取

* 从今天往前beforeDay天到明天凌晨的时间范围,集合范围: [开始时间, 结束时间)

*@return

*/

public static String[] getTodayDateRangeStr0(intbeforeDay) {

Date[] dates=getTodayDateRange(beforeDay);

String star

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值