Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8259393
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 8, 20262026-06-08T02:51:11+00:00 2026-06-08T02:51:11+00:00

I’m making the same query to get Calendar events two different ways. The odd

  • 0

I’m making the same query to get Calendar events two different ways. The odd thing is, one way it works, the other way it doesn’t, even though everything is nearly exactly the same. Using the timeMin, timeMax on Google’s API Explorer returns bad request for the time that the second method is sending.

Not only that, but the Google Calendar API docs say the field should be start-min and start-max while the client and the API Explorer say the field should be timeMin and timeMax.

Here’s the code for method 1 that works:

void setPeriod() {
    Date nowDate = new Date();
    startTime = new DateTime(nowDate);
    Time t = new Time();
    t.setToNow();
    t.hour = 23;
    t.minute = 59;
    nowDate.setTime(t.toMillis(false));
    endTime = new DateTime(nowDate);
}

new AsyncTask<Void, Void, Void>() {
@Override
protected Void doInBackground(Void... params) {
    try {
    Events evlist = g.getClient().events().list(calendarIds.get(cal)).setTimeMin(startTime).setTimeMax(endTime).execute();
    if (evlist.getItems() != null) {
        //Parse the events
    ...
}.execute();

Method 2:

new AsyncTask<Void, Void, List<Event>>() {
    @Override
protected List<Event> doInBackground(Void... arg0) {
    Date nowDate = new Date();
    DateTime startTime = new DateTime(nowDate);
    Time t = new Time();
    t.setToNow();
    t.hour = 23;
    t.minute = 59;
    nowDate.setTime(t.toMillis(true));
    DateTime endTime = new DateTime(nowDate);
    Calendar client = com.google.api.services.calendar.Calendar
                .builder(transport, jsonFactory)
                .setApplicationName("Wayk by Senti")
                .setHttpRequestInitializer(
                    new HttpRequestInitializer() {
                        public void initialize(HttpRequest request)
                                        throws IOException {
                                    request.getHeaders()
                                            .setAuthorization(
                                                    GoogleHeaders
                                                            .getGoogleLoginValue(authToken));
                                }
                            })
                    .setJsonHttpRequestInitializer(
                            new JsonHttpRequestInitializer() {

                                public void initialize(
                                        JsonHttpRequest request)
                                        throws IOException {
                                    CalendarRequest calendarRequest = (CalendarRequest) request;
                                    calendarRequest
                                            .setKey(CalendarClientCredentials.KEY);
                                }
                            }).build();
            try {
                List<Event> events = new ArrayList<Event>();
                for (int i = currentCal; i < enables.size(); i++) {
                    if (enables.get(i)) {
                        AiLog.v("Getting events");
                        AiLog.v("AuthToken: " + authToken);
                        AiLog.v("CalendarID: " + calendarIds.get(i));
                        AiLog.v("Calendar name: " + calendarNames.get(i));
                        AiLog.v("Calendar account: " + account);
                        Calendar.Events.List eventReq = client.events()
                                .list(calendarIds.get(i)).setTimeMin(startTime).setTimeMax(endTime).execute();//Bad request here

Note that the client is exactly the same for both. The client in the second method successfully grabs the list of calendars for the account. I have verified that the calendar ID is correct, which leaves me with the error coming from startMin and startMax.

Any help appreciated.

Cheers, Z

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-08T02:51:12+00:00Added an answer on June 8, 2026 at 2:51 am

    Figured it out.

    You have to use the DateTime constructor that accepts a TimeZone.

    ie

    DateTime startTime = new DateTime(new Date(), TimeZone.getDefault());
    

    Hope this saves someone else the 16 hours I spent trying to figure this out. Really bad documentation.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm making a simple page using Google Maps API 3. My first. One marker
link Im having trouble converting the html entites into html characters, (&# 8217;) i
I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
I am reading a book about Javascript and jQuery and using one of the
I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this
I have two tables with like below codes: Table: Accounts id | username |
I have a .ini file as follows: [playlist] numberofentries=2 File1=http://87.230.82.17:80 Title1=(#1 - 365/1400) Example
That's pretty much it. I'm using Nokogiri to scrape a web page what has
I have just tried to save a simple *.rtf file with some websites and
I want to count how many characters a certain string has in PHP, but

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.