fork download
  1. /* package whatever; // don't place package name! */
  2.  
  3. import java.util.*;
  4. import java.lang.*;
  5. import java.io.*;
  6.  
  7. /* Name of the class has to be "Main" only if the class is public. */
  8. class Ideone
  9. {
  10. public static void main (String[] args) throws java.lang.Exception
  11. {
  12.  
  13. List < String > strings = new ArrayList <>(
  14. List.of(
  15. "2015-08-27T22:24:31.903" ,
  16. "2018-08-27T22:24:31.903" ,
  17. "2016-08-27T22:24:31.903" ,
  18. "2017-08-27T22:24:31.903"
  19. )
  20. );
  21. strings.sort( Comparator.naturalOrder() );
  22.  
  23. System.out.println( "strings = " + strings );
  24.  
  25.  
  26. }
  27. }
Success #stdin #stdout 0.15s 36000KB
stdin
Standard input is empty
stdout
strings = [2015-08-27T22:24:31.903, 2016-08-27T22:24:31.903, 2017-08-27T22:24:31.903, 2018-08-27T22:24:31.903]