我試圖顯示通過我的webapp中的HTTP請求發送的日期。服務器中顯示的日期與我預期的不同
在區域環境中,發送的日期顯示正確,但是當webapp部署在服務器上時,顯示的日期對應於服務器上的當前日期,而不是我發送的日期。 HTTP請求的
例子: 發送HTTP請求: HTTP:// ... persoDate = 「2013年3月10日11時29分55秒」
這裏是我的代碼:
def initDate = new SimpleDateFormat("d/M/yyyy H:m:s").parse(params["persoDate"].replaceAll(/"/, ''))
MyInstance.addToAbList(new BOSSession(setDateSession:initDate))
MyInstance.save(flush: true)
我發現有關此常規區的一些信息: http://groovy.codeplex.com/wikipage?title=Dates%20and%20Times 但我不知道如何在我的代碼中包括TimeZone 我基於在法國添加,所以在我的代碼中添加了這一行: System.setProperty('user.timezone','GMT') – Jils
我也試過這個: initDate.setTimeZone(時區。getTimeZone(「GMT」)) 但我有錯誤: groovy.lang.MissingMethodException:沒有方法的簽名:java.util.Date.setTimeZone()適用於參數類型:(sun.util.calendar.ZoneInfo)值:[sun.util.calendar.ZoneInfo [id =「GMT」,offset = 0,dstSavings = 0,useDaylight = false,transitions = 0,lastRule = null]] 可能的解決方案:setTime(long) – Jils
感謝您的解釋,我會按照這些步驟找出解決方案。 – Jils