55355

Sorting list having itemBean by date?

Question:

how to sort a list by date in android

List<ItemBean> listIB = new ArrayList<ItemBean>(); for(int i=0; i<DispLibActivity.itemListVect.size(); i++) { listIB.add(DispLibActivity.itemListVect.get(i)); }

ItemBean class have a member date

public class ItemBean implements Parcelable{ String item_id, item_title, image_url, link_url, description, publish_date, in_app_date, sub_section_id, type, duration, orig_url, sync; .... .... }

I want to sort list "listIB" with its member "publish_date"

Answer1:

use SimpleDateFormat to parse the date string, get the Date object and confront the time in milliseconds in a comparator.

Recommend

  • How do I preserve data objects in Android/Java?
  • Android implement Parcelable object which has hashmap
  • Dynamically Impersonate a remote user - c# and asp.net
  • Angularfire2.5 Real Time Database with angular material autocomplete
  • Combinatios in List of LIsts Prolog
  • Why have a private constructor [duplicate]
  • Test-Path / System.IO.Directory::Exists not working as expected
  • Default parameter using another parameter
  • Name hiding in constructor initialization list
  • ansible playbook unable to continue as the `tar` fails due to `file change as we read`
  • Passing and ArrayList through intent
  • JSONPath Syntax when dot in key
  • Reflection / C# typing errors when publishing an F# class implementing an interface
  • SQL - count occurrences of gender
  • How to get a list with description of all dba packages
  • Reassigning an array frees the memory used by it?
  • hibernate sets dirty flag (and issues update) even though client did not change value
  • C++ friend class std::vector
  • Regarding starting the threads on a condition
  • SetWindowsHookEx does not react on media keys
  • Change multiple background-images with jQuery
  • How to access EntityManager inside Entity class in EJB3
  • Android screen density dpi vs ppi
  • Opengl-es onTouchEvents problem or a draw problem? [closed]
  • output of program is not same as passed argument
  • DirectX11 ClearRenderTargetViewback with transparent buffer?
  • Change an a tag attribute in JavaScript based on screen width
  • Cannot Parse HTML Data Using Android / JSOUP
  • Windows forms listbox.selecteditem displaying “System.Data.DataRowView” instead of actual value
  • Unit Testing MVC Web Application in Visual Studio and Problem with QTAgent
  • Angular 2 constructor injection vs direct access
  • Trying to get generic when generic is not available
  • Java static initializers and reflection
  • Android Google Maps API OnLocationChanged only called once
  • apache spark aggregate function using min value
  • unknown Exception android
  • Sorting a 2D array using the second column C++
  • Observable and ngFor in Angular 2
  • UserPrincipal.Current returns apppool on IIS
  • Unable to use reactive element in my shiny app