Skip to main content
formatting, tags.
Source Link
Quentin Pradet
  • 7.1k
  • 1
  • 25
  • 44

I was refactoring some code and found this:

 

DateTime CurrentDateTime = System.now();
Datetime ESTDate = Datetime.newInstance(CurrentDateTime.year(),CurrentDateTime.month(),CurrentDateTime.day(),CurrentDateTime.hour(),CurrentDateTime.minute(),CurrentDateTime.second());
String myDateFormat = ESTDate.format('yyyy-MM-dd hh:mm:ss');
String myDate = myDateFormat.replace(' ', 'T');
object1.birthDate = myDate;


And I changed it to
> object1.birthDate = datetime.now().format('yyyy-MM-dd\'T\'hh:mm:ss');
CurrentDateTime isn't used anywhere just in those four lines.
DateTime CurrentDateTime = System.now(); Datetime ESTDate = Datetime.newInstance(CurrentDateTime.year(),CurrentDateTime.month(),CurrentDateTime.day(),CurrentDateTime.hour(),CurrentDateTime.minute(),CurrentDateTime.second()); String myDateFormat = ESTDate.format('yyyy-MM-dd hh:mm:ss'); String myDate = myDateFormat.replace(' ', 'T'); object1.birthDate = myDate; 
How a programmer can even do that? Or WHY?

And I changed it to



 
object1.birthDate = datetime.now().format('yyyy-MM-dd\'T\'hh:mm:ss'); 
Tags: apex-code force.com salesforce

CurrentDateTime isn't used anywhere just in those four lines. How a programmer can even do that? Or WHY?

I was refactoring some code and found this:

 

DateTime CurrentDateTime = System.now();
Datetime ESTDate = Datetime.newInstance(CurrentDateTime.year(),CurrentDateTime.month(),CurrentDateTime.day(),CurrentDateTime.hour(),CurrentDateTime.minute(),CurrentDateTime.second());
String myDateFormat = ESTDate.format('yyyy-MM-dd hh:mm:ss');
String myDate = myDateFormat.replace(' ', 'T');
object1.birthDate = myDate;


And I changed it to
> object1.birthDate = datetime.now().format('yyyy-MM-dd\'T\'hh:mm:ss');
CurrentDateTime isn't used anywhere just in those four lines. How a programmer can even do that? Or WHY?

  Tags: apex-code force.com salesforce

I was refactoring some code and found this:

DateTime CurrentDateTime = System.now(); Datetime ESTDate = Datetime.newInstance(CurrentDateTime.year(),CurrentDateTime.month(),CurrentDateTime.day(),CurrentDateTime.hour(),CurrentDateTime.minute(),CurrentDateTime.second()); String myDateFormat = ESTDate.format('yyyy-MM-dd hh:mm:ss'); String myDate = myDateFormat.replace(' ', 'T'); object1.birthDate = myDate; 

And I changed it to

object1.birthDate = datetime.now().format('yyyy-MM-dd\'T\'hh:mm:ss'); 

CurrentDateTime isn't used anywhere just in those four lines. How a programmer can even do that? Or WHY?

Source Link

Format current date

I was refactoring some code and found this:

DateTime CurrentDateTime = System.now();
Datetime ESTDate = Datetime.newInstance(CurrentDateTime.year(),CurrentDateTime.month(),CurrentDateTime.day(),CurrentDateTime.hour(),CurrentDateTime.minute(),CurrentDateTime.second());
String myDateFormat = ESTDate.format('yyyy-MM-dd hh:mm:ss');
String myDate = myDateFormat.replace(' ', 'T');
object1.birthDate = myDate;


And I changed it to
> object1.birthDate = datetime.now().format('yyyy-MM-dd\'T\'hh:mm:ss');
CurrentDateTime isn't used anywhere just in those four lines. How a programmer can even do that? Or WHY?

Tags: apex-code force.com salesforce