Question: how to change the format of current date in java?
Answer: Here is an example of formatting a date into a StringBuffer using Java SimpleDateFormat : StringBuffer stringBuffer = new StringBuffer(); Date now = new Date(); SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ssZ"); simpleDateFormat. format(now, stringBuffer, new FieldPosition(0));