2017-08-31 10 views
0

JavaのGoogle APIクライアントを使用していますが、Googleカレンダーイベントを作成しようとしています。 すでに作成したイベントにログインして取得できます。(Java)イベントを挿入するときのGoogleカレンダー形式のエラー

私はAPIの例を以下してきたと私は次のエラーを取得し、他の同様の質問を見て、まだそれが働いて得ることができませんよ。

com.google.api.client.googleapis.json.GoogleJsonResponseException: 400 Bad Request 
{ 
    "code" : 400, 
    "errors" : [ { 
"domain" : "global", 
"message" : "Invalid value for: \"T\" found, can only parse bare date string: 2017-08-31T12:00:00.000-01:00 Have you accidentally used DateTime instead of a Date?", 
"reason" : "invalid" 
    } ], 
    "message" : "Invalid value for: \"T\" found, can only parse bare date string: 2017-08-31T12:00:00.000-01:00 Have you accidentally used DateTime instead of a Date?" 
} 

これは私のコードですが、私は」私のDateTimesに文字列を渡す:

DateTime startDate = new DateTime(startData); 
    EventDateTime start = new EventDateTime(); 
    start.setDate(startDate); 
    start.setTimeZone("Europe/Stockholm"); 
    DateTime endDate = new DateTime(endData); 
    EventDateTime end = new EventDateTime(); 
    end.setDate(endDate); 
    end.setTimeZone("Europe/Stockholm"); 
    Event event = new Event(); 
    event.setDescription(lessons.get(i).getDescription()); 
    event.setStart(start); 
    event.setEnd(end); 
    event.setLocation(lessons.get(i).getLocation()); 
    event.setSummary(lessons.get(i).getName()) 

何が問題なのでしょうか?

答えて

0

可能な重複

ただし、まもなく、はい、DateTime形式を必要とする関数を使用しようとしていますが、異なる日付オブジェクトのパラメータとしてパラメータとして使用しています。

"新しいDateTime(startData);" startDataはDateTimeではなくdateです。

この記事をチェックアウトしてください:Google Calendar API (Java) - Invalid time format when creating Google Calendar Event

それはあなたの問題と、それには2つのソリューションを提供しています。

+0

あなたはそうです、結局のところ、私は正しく他の答えをチェックしていませんでした。私はこれを非常に疲れていると非難します。この質問を閉じることはできますか? – Melrache

+0

@Melrache、あなたはそのチェックマークをチェックしてこれを答えとしてマークすることで問題を閉じることができます。 – noogui

関連する問題