fork download
  1. import java.util.*;
  2. import java.lang.*;
  3. import java.io.*;
  4. import java.text.SimpleDateFormat;
  5.  
  6. /* Name of the class has to be "Main" only if the class is public. */
  7. class Ideone
  8. {
  9. public static void main (String[] args) throws java.lang.Exception
  10. {
  11.  
  12. Date d = ( new SimpleDateFormat("yyyy-MM-dd-HH.mm.ss.SSS", Locale.US) ).parse("2015-08-10-14.20.40.679279");
  13. System.out.println(new SimpleDateFormat("yyyy-MM-dd-HH.mm.ss.S").format(d));
  14. System.out.println(new SimpleDateFormat("yyyy-MM-dd-HH.mm.ss.SS").format(d));
  15. System.out.println(new SimpleDateFormat("yyyy-MM-dd-HH.mm.ss.SSS").format(d));
  16.  
  17. Date dd = ( new SimpleDateFormat("yyyy-MM-dd-HH.mm.ss.SSS", Locale.US) ).parse("2015-08-10-14.20.40.679");
  18. System.out.println(new SimpleDateFormat("yyyy-MM-dd-HH.mm.ss.S").format(dd));
  19. System.out.println(new SimpleDateFormat("yyyy-MM-dd-HH.mm.ss.SS").format(dd));
  20. System.out.println(new SimpleDateFormat("yyyy-MM-dd-HH.mm.ss.SSS").format(dd));
  21.  
  22.  
  23. }
  24. }
Success #stdin #stdout 0.14s 321280KB
stdin
Standard input is empty
stdout
2015-08-10-14.31.59.279
2015-08-10-14.31.59.279
2015-08-10-14.31.59.279
2015-08-10-14.20.40.679
2015-08-10-14.20.40.679
2015-08-10-14.20.40.679