Quickest & Easiest Way To Sort Date Array In Java

Published: 14 July 2020
on channel: Unpossible POG
4,695
26

Quickest way to sort date-time array in JAVA.

Code Link:-
https://unpossiblepog.blogspot.com/20...

Subscribe my Channel:-
http://www.youtube.com/user/SanketRoo...

Facebook Page:-
  / unpossiblens  

Twitter Account:-
  / unpossiblepog  

Blog :-
https://unpossiblepog.blogspot.in/
------------------------------------------------

Hey guys.
In this video, we shall sort date-time array in java in the quickest and easiest way possible.
This technique has one drawback which i shall explain at the ending of this video.
I already created a file and inside it there is a string array which has format of like date-time.
I am recommending you to use netbeans as it provides auto-suggestions.
We are going to need a SimpleDateFormat class.
Import required package.
Then we are using set & treeset with LONG as data-type.
In for loop, we are going to find out the length of array and add each array element in set.
but before that, we are converting date-string into long number using simpledateformat’s function called getTime().

The SET class already ordered data in ascending order.
Then we are going to use FOR:EACH loop.
and in that, we call each data and again convert long into Date-time format.

As per input and output, 2018 should be at the top.
Also, if date is same but hours and minutes are different, then also those values get sorted.

The only drawback of this technique is that, it skips one element if that same element is already present in array.

Code link & other required links are given in the description.
Don’t forget to like, share and subscribe.
Thanks for watching.


On this page of the site you can watch the video online Quickest & Easiest Way To Sort Date Array In Java with a duration of hours minute second in good quality, which was uploaded by the user Unpossible POG 14 July 2020, share the link with friends and acquaintances, this video has already been watched 4,695 times on youtube and it was liked by 26 viewers. Enjoy your viewing!