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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T21:33:59+00:00 2026-06-13T21:33:59+00:00

i get json data and i want to i get date and nulldate store

  • 0

i get json data and i want to i get date and nulldate store in arrylist .how to sort date and null date data set in listview sort date in below. i store in all data in All_Approval_data_dto class.
my code given below: please check it and what i missing it?

static final Comparator<All_Approval_data_dto> byDate = new Comparator<All_Approval_data_dto>() {
        SimpleDateFormat sdf = new SimpleDateFormat("MM/dd/yyyy hh:mm:ss a");

        public int compare(All_Approval_data_dto ord1,
                All_Approval_data_dto ord2) {

            java.util.Date d1 = null;
            java.util.Date d2 = null;
            try {
                d1 = sdf.parse(ord1.lastModifiedDate);
                d2 = sdf.parse(ord2.lastModifiedDate);
                if (d1 == null) {
                    return (d2 == null) ? 0 : -1;
                }
                if (d2 == null) {
                    return 1;
                }

            } catch (java.text.ParseException e) {
                // TODO Auto-generated catch block`
                e.printStackTrace();
            }

            return (d1.getTime() > d2.getTime() ? -1 : 1); // descending
            // return (d1.getTime() > d2.getTime() ? 1 : -1); //ascending
        }

    };

My error in below:

11-02 11:03:58.861: ERROR/AndroidRuntime(473): FATAL EXCEPTION: main
11-02 11:03:58.861: ERROR/AndroidRuntime(473): java.lang.NullPointerException
11-02 11:03:58.861: ERROR/AndroidRuntime(473):     at java.text.SimpleDateFormat.parse(SimpleDateFormat.java:1201)
11-02 11:03:58.861: ERROR/AndroidRuntime(473):     at java.text.DateFormat.parse(DateFormat.java:642)
11-02 11:03:58.861: ERROR/AndroidRuntime(473):     at com.serana.Approval$2.compare(Approval.java:155)
11-02 11:03:58.861: ERROR/AndroidRuntime(473):     at com.serana.Approval$2.compare(Approval.java:1)
11-02 11:03:58.861: ERROR/AndroidRuntime(473):     at java.util.TimSort.countRunAndMakeAscending(TimSort.java:320)
11-02 11:03:58.861: ERROR/AndroidRuntime(473):     at java.util.TimSort.sort(TimSort.java:185)
11-02 11:03:58.861: ERROR/AndroidRuntime(473):     at java.util.TimSort.sort(TimSort.java:169)
11-02 11:03:58.861: ERROR/AndroidRuntime(473):     at java.util.Arrays.sort(Arrays.java:1907)
11-02 11:03:58.861: ERROR/AndroidRuntime(473):     at java.util.Collections.sort(Collections.java:1972)
11-02 11:03:58.861: ERROR/AndroidRuntime(473):     at com.serana.Approval$4.onItemSelected(Approval.java:79)
11-02 11:03:58.861: ERROR/AndroidRuntime(473):     at android.widget.AdapterView.fireOnSelected(AdapterView.java:864)
11-02 11:03:58.861: ERROR/AndroidRuntime(473):     at android.widget.AdapterView.access$200(AdapterView.java:42)
11-02 11:03:58.861: ERROR/AndroidRuntime(473):     at android.widget.AdapterView$SelectionNotifier.run(AdapterView.java:830)
11-02 11:03:58.861: ERROR/AndroidRuntime(473):     at android.os.Handler.handleCallback(Handler.java:587)
11-02 11:03:58.861: ERROR/AndroidRuntime(473):     at android.os.Handler.dispatchMessage(Handler.java:92)
11-02 11:03:58.861: ERROR/AndroidRuntime(473):     at android.os.Looper.loop(Looper.java:123)
11-02 11:03:58.861: ERROR/AndroidRuntime(473):     at android.app.ActivityThread.main(ActivityThread.java:4627)
11-02 11:03:58.861: ERROR/AndroidRuntime(473):     at java.lang.reflect.Method.invokeNative(Native Method)
11-02 11:03:58.861: ERROR/AndroidRuntime(473):     at java.lang.reflect.Method.invoke(Method.java:521)
11-02 11:03:58.861: ERROR/AndroidRuntime(473):     at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:868)
11-02 11:03:58.861: ERROR/AndroidRuntime(473):     at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:626)
11-02 11:03:58.861: ERROR/AndroidRuntime(473):     at dalvik.system.NativeStart.main(Native Method)
  • 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-13T21:34:00+00:00Added an answer on June 13, 2026 at 9:34 pm

    please replace your try/catch block with this code

    try {
    
                if (d1 == null) {
                    return (d2 == null) ? 0 : -1;
                }
                if (d2 == null) {
                    return 1;
                }
    
                d1 = sdf.parse(ord1.lastModifiedDate);
                d2 = sdf.parse(ord2.lastModifiedDate);
    
            } catch (java.text.ParseException e) {
                // TODO Auto-generated catch block`
                e.printStackTrace();
            }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

What I want to do is to get Json data out as a list
I want use php curl with oauth to get the JSON data from twitter
In my project ,I get json data from Server,there's a field named 'creat_at' in
I can connect to server and get json data. it is in this format:
I'm trying to get some json data in my application, but it won't come
I have a website where an ajax call will get some Json data from
Is there any method I can get the full JSON data from jqGrid when
I have a manager class, which update json data from web, get values... The
JavaScript/JQuery var arr=[]; $('.element').each(function(i) { arr.push({id:i,value:$(this).attr('data-value')}); }); $.get('/json.php?arr='+arr,function(result) { alert(result); }); PHP <?php $j
I'm trying to get a JSON response and iterate through the data. Here is

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.