We help IT Professionals succeed at work.

help required on Date format on java 8

roy_sanu
roy_sanu asked
on
why data format is being set like this below on createdDate ? IS this correct expert ?
@Override
      public void buildObjectMap() {
            super.buildObjectMap();
            Map<String, Object> objectMap =  getObjectMap();
            
            objectMap.put("user_id", worker.getUsername());
            objectMap.put("session_id", session_id);
            objectMap.put("imei1", imei1);
            objectMap.put("imei2", imei2);
            objectMap.put("macId", macId);
            objectMap.put("session_id", session_id);
            // Date format is defined but it is used in the created_Date format which has been specified here
          DateFormat dateFormat = new SimpleDateFormat("yyyy-mm-dd hh:mm:ss");  
       // String strDate = dateFormat.format(super.getCreated());  
            objectMap.put("created_Date",createdDate);
      }
Comment
Watch Question

CERTIFIED EXPERT

Commented:
what is the result of super.getCreated() ???
roy_sanudeveloper

Author

Commented:
Expert that part is being commented out.please provide me an alternate solution on date as I am new to this code base.My question is how to use date format as
"yyyy-mm-dd hh:mm:ss" on

objectMap.put("created_Date",createdDate);

Any suggestions? Expert.
CERTIFIED EXPERT
Commented:
Date date = new Date();   or Date date = Calendar.getInstance().getTime();  
             

   DateFormat dateFormat = new SimpleDateFormat("yyyy-mm-dd hh:mm:ss");  
                String strDate = dateFormat.format(date);
roy_sanudeveloper

Author

Commented:
Thanx satish expert so kind of you.

My Best Regards
Roy Daisy.