content: package com.an.room.util;
  
  import android.app.Activity;
  import android.content.Context;
  import android.os.Handler;
  import android.util.Base64;
  import android.view.inputmethod.InputMethodManager;
  import android.widget.Toast;
  
  import java.security.MessageDigest;
  import java.security.NoSuchAlgorithmException;
  import java.text.DateFormat;
  import java.text.ParseException;
  import java.text.SimpleDateFormat;
  import java.time.LocalDateTime;
  import java.time.format.DateTimeFormatter;
  import java.util.Calendar;
  import java.util.Date;
  
  public class AppUtils {
  
  
      public static Date getCurrentDateTime(){
          Date currentDate =  Calendar.getInstance().getTime();
          return currentDate;
      }
  
      public static String getFormattedDateString(Date date) {
  
          try {
  
              SimpleDateFormat spf = new SimpleDateFormat("EEE MMM d HH:mm:ss zzz yyyy");
              String dateString = spf.format(date);
  
              Date newDate = spf.parse(dateString);
              spf= new SimpleDateFormat("dd MMM yyyy HH:mm:ss");
              return spf.format(newDate);
  
          } catch (ParseException e) {
              e.printStackTrace();
          }
          return null;
      }
  
      public static String generateHash(String password) {
          MessageDigest md = null;
          try {
              md = MessageDigest.getInstance("SHA-512");
              md.update(password.getBytes());
              byte byteData[] = md.digest();
              String base64 = Base64.encodeToString(byteData, Base64.NO_WRAP);
              return base64;
  
          } catch (NoSuchAlgorithmException e) {
              e.printStackTrace();
          }
          return null;
      }
  
      public static void showMessage(Context context, String message) {
          Toast.makeText(context, message, Toast.LENGTH_LONG).show();
      }
  
      public static void openKeyboard(final Context context) {
          new Handler().postDelayed(new Runnable() {
              @Override
              public void run() {
                  InputMethodManager imm = (InputMethodManager) context.getSystemService(Context.INPUT_METHOD_SERVICE);
                  if (imm != null) {
                      imm.toggleSoftInput(InputMethodManager.SHOW_FORCED, InputMethodManager.HIDE_IMPLICIT_ONLY);
                  }
              }
          }, 500);
      }
  
      public static void hideKeyboard(Activity activity) {
          InputMethodManager inputMethodManager = (InputMethodManager) activity.getSystemService(Activity.INPUT_METHOD_SERVICE);
          inputMethodManager.hideSoftInputFromWindow(activity.getCurrentFocus().getWindowToken(), 0);
      }
  }
  