-8

Is there a simple function to convert a time that's like this: 10:30pm 17 Aug 2016 NZST to 2016-8-17-2230

thunder0
  • 3
  • 1

1 Answers1

0
import java.text.SimpleDateFormat;
import java.util.Date;

public class Main {
   public static void main(String [] args) throws Exception {
       SimpleDateFormat displayFormat = new SimpleDateFormat("yyyy-MM-dd-HHmm");

       Date date = new Date();//Current Date 
       System.out.println(displayFormat.format(date));
   }
}




See Java Documentation
http://docs.oracle.com/javase/1.5.0/docs/api/java/text/SimpleDateFormat.html
Yasir Shabbir Choudhary
  • 2,458
  • 2
  • 27
  • 31