【问题标题】:How to print current date and date -7 days如何打印当前日期和日期-7天
【发布时间】:2023-02-23 04:54:39
【问题描述】:

如何打印当前日期和日期-7天

如何打印当前日期和日期-7天 * def getDate = function(7){def date = new Date();date.setDate(date.getDate() - (7));return date.toString()} * 打印获取日期

【问题讨论】:

标签: karate


【解决方案1】:
* def currentDate = Java.type('java.time.LocalDate').now().format(Java.type('java.time.format.DateTimeFormatter').ofPattern('yyyy-MM-dd'))
* def pastDate = Java.type('java.time.LocalDate').now().minusDays(7).format(Java.type('java.time.format.DateTimeFormatter').ofPattern('yyyy-MM-dd'))
* print('Current Date: ' + currentDate)
* print('Date -7 Days: ' + pastDate)

【讨论】:

    猜你喜欢
    • 2022-08-18
    • 1970-01-01
    • 2018-10-25
    • 2012-04-29
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2012-08-12
    • 2021-11-09
    相关资源
    最近更新 更多