Skip to content

Instantly share code, notes, and snippets.

@wszdwp
Last active August 29, 2015 14:24
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save wszdwp/da66daa12745f3dba3d4 to your computer and use it in GitHub Desktop.
Save wszdwp/da66daa12745f3dba3d4 to your computer and use it in GitHub Desktop.
Some java Utility functions
import java.text.DateFormat;
import java.text.SimpleDateFormat;
import java.util.Locale;
public class MyJavaUtility {
private static final String FORMAT1 = "EEEE, MMM d, yyyy hh:mm aaa"; //Wednesday, Jul 1, 2015 02:25 PM
//Date and Time in Java
public static String getTodaysDateAndTime(String format) {
DateFormat dateFormat = new SimpleDateFormat(format, Locale.US);
String dateTimeString = dateFormat.format(System.currentTimeMillis());
return dateTimeString;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment