누구나 정확하게 계산되지 않는 이유를 알 수 있습니다. 시간을 1 초 추가하려고하는데 서식을 적용 할 때 60 밀리 초가 추가되는 것 같습니다. 19 :Groovy : 날짜가 올바르게 계산되지 않습니까? TimeCategory를 사용하여
import java.text.*
import java.util.*
import groovy.time.TimeCategory
def xmlSlurper = new groovy.util.XmlSlurper()
// Get the previous total for number of journals
def journalCountProp = testRunner.testCase.getTestStepByName("Properties")
def journalCountTotal = journalCountProp.getPropertyValue("journalCount")
log.info " 1. Previous JournalCount from last run: "+journalCountTotal
def lastDateProp = testRunner.testCase.getTestStepByName("Properties")
def lastDateHolder = lastDateProp.getPropertyValue("journalQueryDate")
log.info " 2. Previous lastDate from last run: "+lastDateHolder
// Get the response for a given timeline
def response = xmlSlurper.parseText(context.expand('${GET Journal using JournalDate#Response}'));
def currentJournalCount = response.Journals.Journal.size()
log.info " 3. Number of Journals in this Run: "+currentJournalCount
//Getting the date from the last Journal (including an offset as the array count starts at 0)
def lastDate = response.Journals.Journal[currentJournalCount-1].CreatedDateUTC
log.info " 4. CreatedDate from last journal in this response: "+lastDate
//log.info response.Journals.Journal[currentJournalCount-1].CreatedDateUTC
def newdate = Date.parse("yyyy-MM-dd'T'HH:mm:ss.mmm",lastDate.toString())
log.info "dateBeforeChange: "+newdate.format("yyyy-MM-dd'T'HH:mm:ss.mmm")
use(TimeCategory){
newdate = newdate+1.seconds
}
log.info "date After Change: "+newdate.format("yyyy-MM-dd'T'hh:mm:ss.mmm")
log.info " 5. "+newdate.format("yyyy-MM-dd'T'HH:ss:mmm")
출력 :이 응답의 마지막 저널에서
CreatedDate : 2007-03-29T23 52.073
dateBeforeChange : 2007-03-30T00 : 13 : 52.013
날짜 변경 후 : 2007 -03-30T12 : 13 : 53.013
알아낼 수 없습니까? !!
건배, - hh
가 "/시 (1-12) 오전에 시간"을 의미하는 반면 리처드
버려진 질문. "감사". – robbbert
안녕하세요 로버트? 내가 위에 "귀하의 의견을"확실하지? stackoverflow 초보자 인 나는 당신에게 녹색 진드기를주는 것을 간과했을지도 모른다. 지금은 고쳐 졌어. –