Advertisement
Rukes

Untitled

Mar 17th, 2022
775
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1.     public static String getCurrentTime() {
  2.         return getCurrentTime("yyyy/MM/dd HH:mm:ss");
  3.     }
  4.  
  5.     public static String getTimeFormatted(long millis, String format) {
  6.         Date date = new Date(millis);
  7.         DateFormat formatter = new SimpleDateFormat(format);
  8.         return formatter.format(date);
  9.     }
  10.  
  11.     public static String getTimeFormatted(Date date, String format) {
  12.         DateFormat formatter = new SimpleDateFormat(format);
  13.         return formatter.format(date);
  14.     }
  15.  
  16.     public static String getTimeFormatted(long millis) {
  17.         return getTimeFormatted(millis, "HH:mm:ss dd.MM. yyyy");
  18.     }
  19.  
  20.     public static String getCurrentUserTime() {
  21.         return getTimeFormatted(System.currentTimeMillis());
  22.     }
  23.  
  24.     public static String getCurrentTime(String format) {
  25.         DateFormat dateFormat = new SimpleDateFormat(format);
  26.         Calendar calendar = Calendar.getInstance();
  27.         return dateFormat.format(calendar.getTime());
  28.     }
Advertisement
RAW Paste Data Copied
Advertisement