2012-05-25 26 views
1

我試圖撥打:日期亞馬遜土耳其人REST調用Java

https://mechanicalturk.amazonaws.com/?Service=AWSMechanicalTurkRequester 
&AWSAccessKeyId=[the Requester's Access Key ID] 
&Version=2012-03-25 
&Operation=ApproveRejectedAssignment 
&Signature=[signature for this request] 
&Timestamp=[your system's local time] 
&AssignmentId=123RVWYBAZW00EXAMPLE456RVWYBAZW00EXAMPLE 

我需要簽名,這需要的格式YYYY:dd:MMTHH:mm:ss-Offset2012-05-25T11:30:47-07:00

我試圖使用UTC時間戳java工具給出了here來進行簽名,但我無法正確格式化日期。

我也是使用SDK的遊戲,但無法弄清楚甚至從哪裏開始。

回答

1
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ssZ"); 
    Date date = new Date(System.currentTimeMillis()); 
    System.out.println(sdf.format(date)); // 2012-06-23T00:03:52-0700 
1
SimpleDateFormat dateFormatGmt = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); 
    dateFormatGmt.setTimeZone(TimeZone.getTimeZone("GMT")); 

    //Local time zone 
    SimpleDateFormat dateFormatLocal = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); 

    //Time in GMT 
    String[] datetime = dateFormatGmt.format(new Date()).split(" "); 
    String date = datetime[0]; 
    String time = datetime[1]; 

    System.out.print(date+"T"+time+"Z");