from datetime import datetime


def str2datetime(str_time):
  """
  Converts a datetime object into the string format used in the system.
  For consistency, one should never use their own method of converting to string, always use this method.

  Usage: ::\n
    date = utils.datetimeNow()
    date_str = utils.datetime2str(date)
    utils.str2datetime(date_str)
  """
  try:
    return datetime.strptime(str_time,'%Y-%m-%d %H:%M:%S.%f')
  except:
    return datetime.strptime(str_time,'%Y-%m-%d %H:%M:%S')