import java.text.*; import java.util.*; class DateParser { public static void main(String[] args) { if (args.length != 1) { System.out.println("Usage: DateParser "); return; } // Construct a Date Formatter df // It will accept string of the form of "Jan 01, 2004 13:00:00 AM GMT" DateFormat df = DateFormat.getDateTimeInstance(DateFormat.MEDIUM, DateFormat.LONG); try { Date d = df.parse(args[0]); if (d != null) { System.out.println((d.getTime() / 1000) + " secs since Jan 1, 1970 00:00:00 AM GMT"); } } catch (Exception e) { System.err.println("Exception: " + e); return; } } }