This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
String dateStr = Date.today().format(); | |
System.debug('>>>>' + dateStr); | |
System.assertEquals(dateStr, '4/24/2015'); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Date dToday = Date.today(); | |
String dateStr = dToday.year() + '/' + dToday.month() + '/' + dToday.day(); | |
System.debug('>>>>' + dateStr); | |
System.assertEquals(dateStr, '2015/4/24'); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Date dToday = Date.today(); | |
String dateStr = Date.today().format(); | |
DateTime dt = DateTime.newInstance(dToday.year(), dToday.month(),dToday.day()); | |
String dateStr = dt.format('yyyy/MM/dd'); | |
System.debug('>>>>' + dateStr); | |
System.assertEquals(dateStr, '2015/04/24'); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
DateTime dt = DateTime.now(); | |
String dateTimeStr = dt.format('yyyy/MM/dd hh:mm:ss'); | |
System.debug('>>>>' + dateTimeStr); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<apex:outputText value="{0,date,yyyy/MM/dd}"> | |
<apex:param value="{!TODAY()}" /> | |
</apex:outputText> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<apex:outputText value="{0,date,yyyy/MM/dd HH:mm:ss}"> | |
<apex:param value="{!NOW()}" /> | |
</apex:outputText> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
TEXT(YEAR(TODAY())) + "/" + TEXT(MONTH(TODAY())) + "/" + TEXT(DAY(TODAY())) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
TEXT(MONTH(DATEVALUE(NOW())))+"/" +TEXT(DAY(DATEVALUE(NOW())))+"/" +TEXT(YEAR(DATEVALUE(NOW()))) & " " & | |
MID(TEXT(NOW()-TZoffset), 12, 2) & ":" & | |
MID(TEXT(NOW()-TZoffset), 15, 2) & ":" & | |
MID(TEXT(NOW()-TZoffset ), 18, 2) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Long startTime = DateTime.now().getTime(); | |
Long finishTime = DateTime.now().getTime(); | |
while ((finishTime - startTime) < 9000) { | |
//sleep for 9s | |
finishTime = DateTime.now().getTime(); | |
} | |
System.assertEquals(Integer.valueOf((finishTime - startTime) / 1000), 9); | |
System.debug('>>> Done from ' + startTime + ' to ' + finishTime); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
17:02:38:037 USER_DEBUG [6]|DEBUG|>>> Done from 1427702549660 to 1427702558660 |