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 6882105
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T05:12:44+00:00 2026-05-27T05:12:44+00:00

My app crashes whenever I try to do this: for (CalendarEvent event : this.ListofEvents){

  • 0

My app crashes whenever I try to do this:

for (CalendarEvent event : this.ListofEvents){

                 String myDate = new String(event.getDate());
                    SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss");
                    try {
                        theDate = format.parse(myDate);
                    } catch (ParseException e) {
                        // TODO Auto-generated catch block
                        e.printStackTrace();
                    }

                    System.out.println(theDate.getDate());
             }

If I just print event.getDate() as a test, it displays all the dates. But when I try to format each date I’m assuming it locks up the phone resources. It’s a fairly large List with many entries.

Perhaps there’s a better method of getting the day, month, and year without taking up all the resources.

  • 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-05-27T05:12:44+00:00Added an answer on May 27, 2026 at 5:12 am

    Why are you creating a DateFormat inside the loop? You create it, use it, and then it goes out of scope for GC in the next iteration.

    Move it outside the loop:

    DateFormat format = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss");
    format.setLenient(false);               
    for (CalendarEvent event : this.ListofEvents){
        // what does event.getDate() return?  A java.util.Date?  If yes, why are you doing this at all?
        String myDate = new String(event.getDate());
        try {
            theDate = format.parse(myDate);
            System.out.println(theDate.getDate());
        } catch (ParseException e) {
            e.printStackTrace();
        }
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Whenever I try to add this line it crashes my app. Am I not
my app crashes often in this for-loop: for (int a = 0; a <=
When trying to authenticate with facebook, my app crashes. It reaches the line new
For some reason whenever i click on my pin the app crashes. there are
My prototype android app (I should mention it's my first) crashes whenever I run
Android crashes whenever this activity is started. here is the code. import java.util.ArrayList; import
I'm trying to debug a crash (likely memory related) but whenever the app crashes
Whenever I tap newButton my app crashes. I am using automatic reference counting. Edit:
My app runs great on the ICS emu. However, using Gingerbread, it crashes whenever
my app crashes when the user tries to delete a row from the UITableView

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.