tracker issue : CF-4194962

select a category, or use search below
(searches all categories and all time range)
Title:

DateFormat() and DateTimeFormat() Returning Inconsistent Values

| View in Tracker

Status/Resolution/Reason: Closed/Fixed/Fixed

Reporter/Name(from Bugbase): Shawn Oden / Shawn Oden (Shawn Oden)

Created: 10/04/2016

Components: Language, DateTime Functions

Versions: 2016

Failure Type: Unspecified

Found In Build/Fixed In Build: CF2016_Final / 302324

Priority/Frequency: Trivial / All users will encounter

Locale/System: English / Win 64

Vote Count: 1

Problem Description: The DateFormat() and DateTimeFormat() functions return inconsistent values based on the capitalization of the mask.

Steps to Reproduce:

n = createDateTime(2015,12,30,11,22,33);
ds = {
	df   : dateFormat(n,"MM/DD/YYYY") ,
	dtf  : dateTimeFormat(n,"MM/DD/YYYY")
} ;
writeDump(ds);

http://trycf.com/gist/f83f2e4f2012f2df08c30e5892d8db9c/acf2016?theme=monokai

Actual Result:
DF = 12/30/2015
DTF = 12/364/2016

Expected Result:
I would expect the results to match. They should probably both be similar to Java SimpleDateFormat, since that seems to be the masking that DateTimeFormat() mostly follows, ie don't allow upper- and lower-case masks in DateFormat().. 

Any Workarounds:
Use lowercase masks for both, and verify that the date position masks don't introduce unexpected behavior.  

In these situations, larger caution for developers may be warranted on the docs pages.

----------------------------- Additional Watson Details -----------------------------

Watson Bug ID:	4194962

External Customer Info:
External Company:  
External Customer Name: Shawn Oden
External Customer Email:  
External Test Config: My Hardware and Environment details: Windows 7 Professional 64-bit with ColdFusion 2016 Update 3 Express Edition.

Attachments:

Comments:

And just a note, this difference will be hard to notice for "YYYY" because it will only occur on about the last 3 days of any given year.
Comment by External U.
1696 | October 04, 2016 10:16:04 AM GMT
Note 2: To exacerbate this issue a little, the Adobe docs for DateTimeFormat() say that "The function also follows Java date time mask. For more information, refer to Date and Time Patterns topic in SimpleDateFormat Java API page.", yet the examples show using "MM" as a mask for months. "MM" in Java is the same as "nn/NN" in ColdFusion. Java SimpleDateFormat is case-sensitive: "mm" is months and "MM" is minutes. And there's also "D/d","H/h","S/s","W/w","Y/y","Z/z". I prefer the CF way of using different letters for each mask to remove ambiguity, but the CF function can't really "follow" Java masking if it treats some upper- and lower-case letters the same where Java and CF overlap (like "M").
Comment by External U.
1697 | October 04, 2016 10:55:13 AM GMT