機械翻訳について

日付間の差異の計算

この例では、Groovyを使用して、日付間の差異を計算して、従業員の試用期間終了日の10日後にEメール・アラートをトリガーする方法を示します。

  1. アクティビティにProbationEndDateという名前のフィールドを作成します。

  2. 差額を計算して、従業員の試用期間終了日から10日後に電子メール・アラートをトリガーするには、次のコードを使用します:

    //Difference between dates
    //Business Scenario: To trigger an email alert exactly after 10 days of Employee Probation End Date.
    if(TRUNC(SYSDATE) - Trunc(${ProbationEndDate}) == 10)
    {
        // Business logic
    }
     
    //To reference the application server's current date and time in any groovy expression, use:
    adf.currentDate
    adf.currentDateTime
     
    //To reference the database's current date and time in any groovy expression, use:
    adf.currentDBDate
    adf.currentDBDateTime
     
    //Returns: the current date, with no time
    println(today())
     
    //Returns the current date and time
    println(now())
     
    //1. Difference between two dates
    def today = new Date()
    def yesterday = today - 1
     
    assert 1 == today.minus(yesterday)
    assert 1 == today - yesterday
     
    //2.  Date.parse() to convert String to Date.
    def date = new Date().parse('yyyy/MM/dd', '2019/12/09')
      
    //3.  We can use [] or getAt() to get date fields.
    assert 2019 == date[Calendar.YEAR]
    assert 11 == date[Calendar.MONTH]
    assert 9 == date.getAt(Calendar.DATE)
     
    //Returns a number representing the month
    def currentMonth=month(new Date())
    def nextMonth = currentMonth + 1
     
    // We can use the + and - operators to add or subtract days.
    def date = new Date().parse('yyyy/MM/dd', '2019/07/22')
    def dateNext = date.clone() +1  // prints --> Tue Jul 23 00:00:00 UTC 2019
    def datePrevious = date.clone() -1  // prints --> Sun Jul 21 00:00:00 UTC 2019
    def nextDay = date + 1  // Or date.plus(1)
    def previousDay = date - 1  // Or date.minus(1)
      
    // ++ operator to move one day ahead.
    dateNext++  // Or dateNext.next()
    assert dateNext == nextDay
      
    // -- operator to move one day back.
    datePrevious--  // Or datePrevious.previous()
    assert datePrevious == previousDay
      
    def otherDate = new Date().parse('yyyy/MM/dd', '2019/07/25')
    // Dates can be used in ranges.
    println((otherDate..<date).size()) // prints -->3
    
    // Date.format() uses java.text.SimpleDateFormat.
    assert '9 December, 2019' == date.format("d MMMM, yyyy")
    assert '12/9/19' == date.getDateString()