Quantcast
Channel: SmartClient Forums
Viewing all articles
Browse latest Browse all 4756

incorrect date formatting using 12 hours

$
0
0
Hi,

Date formatting using
Code:

DateUtil.format(date, 'hh:mm a')
method, formats it with the hours begin from 0 AM to 12 pm. According to SimpleDateFormat java API [1], "h" stands for "Hour in am/pm (1-12)".

Example:

Code:

console.log(isc.DateUtil.format(new Date('Wed Jan 07 2015 00:00:00'), 'hh:mma'));
console.log(isc.DateUtil.format(new Date('Wed Jan 07 2015 12:00:00'), 'hh:mma'));

logs

Code:

00:00 am
12:00 am

whereas equivalent code in Java:

Code:

    SimpleDateFormat sdf = new SimpleDateFormat("HH:mm");
    System.out.println(new SimpleDateFormat("hh:mm a").format(sdf.parse("00:00")));
    System.out.println(new SimpleDateFormat("hh:mm a").format(sdf.parse("12:00")));

logs:
Code:

12:00 AM
12:00 PM


Tested with ISC_100_BRANCH_2015-01-19_1421661957_wayne_limegreen-dev-server


[1] http://docs.oracle.com/javase/7/docs...ateFormat.html

Viewing all articles
Browse latest Browse all 4756

Trending Articles