AEM HTL Number formatting to 2 digits - aem

Is there a number formatter in HTL that can format number to 2 digits. I want
<h2>${ '#' # format=3}</h2>
to render 03 instead of 3.
Is there a HTL way of doing this without taking help from Sling Model?

A regular Java number format pattern can be used: ${"00" # format=3}

Related

how to custom style the number format in crystal report

Suppose I say I have number eg:89000000000 I need to format like 89,00,00,000.00 in this format of Indian numerical system as crores.
The following formula should work:
CStr({TableName.NumberColumnName}, "##,##,##,##,###.##"))
To explicitly specify the digit grouping character, add those parameters:
CStr({TableName.NumberColumnName}, "##,##,##,##,###.##", 2, ",")
(The digit grouping character depends on the system settings if not specified explicitly.)

JCL append date/time to a file?

How do I add the current date/time to a file in JCL?
For example, from the JCL:
//INPUT DD *
CGQ-TEST.ISQCQ.NET
ASCII
LOCSITE SBD=SYSP.FTP.RCAMSI
SENDSITE
PUT 'TJ.UTJ0IR86.BC814.HDR' BC814001.TMP
APPEND 'TJ.UTJ4IR86.BC(0)' BC814001.TMP
APPEND 'TJ.UTJ0IR86.BC814.TRL' BC814001.TMP
RENAME BC813001.TMP BC814001.TXT
CLOSE
QUIT
I need the file BC814001.TXT to actually be BC814001.20160930.110900.ent, where 20160930.110900 is current date and time (YYYYMMDD.HHMMSS format).
The best way to do this is to use the features of your job scheduling package (Control-M or one of its competitors). It's usually the most maintainable. Talk to your production control staff.
If for some reason that won't work for you, please see this answer.
The convention fd dataset level qualifiers limits you only to 8 characters per section (space between dots) and it should start with a character not a number.
Each name segment (qualifier) is 1 to 8 characters, the first of which must be alphabetic (A to Z) or national (# # $). The remaining seven characters are either alphabetic, numeric (0 - 9), national, a hyphen (-). Name segments are separated by a period (.).
For z/OS environments I would go with 'day of the year' for the actual date. For example in your case - BC814001.D2016274.T110900.ent.
To get the current date and time You can refer to the TSO DATE and TSO TIME via REXX and format them the way You like (examples here http://www.rexxla.org/rexxlang/mfc/datec.html) then pass them as a variable to your SYSIN statement.
Regards,
Jarek.

Convert text date format to number date format

I have stored some data entrys in a CSV file in following Format:
Thu Jul 28 08:42:33 GMT+01:00 2016
and need to convert it to just a time stamp (eg. h:m:s). How can I quickly and easily do this?
To convert a text date in a cell to a serial number, you use the DATEVALUE function. Then you copy the formula, select the cells that contain the text dates, and use Paste Special to apply a date format to them. Select a blank cell and verify that its number format is General.
If the size is fixed, then assuming the string is in A1:
=MID(A1,12,8)
The result can then be converted to an actual time value using TIMEVALUE.
Looks like a simple call to a single function would extract the substring you want, since it begins at a specific offset and only runs for eight characters (two hh plus colon plus two mm plus colon plus two ss).

Inverse function to format-date

in xslt 2.0, the function format-date will convert a date to string in a desired format, e.g.
<xsl:value-of select = "format-date(xs:date('2000-01-01'), '[D01] [MN,*-3] [Y0001]', 'en', (), ())"/>
results in
01 JAN 2000.
My question is: which function takes 01 JAN 2000 as input and outputs 2000-01-01?
As noted above:
XPath 3.1 adds parse-ietf-date() which handles many of the date formats used in internet standards such as email (which are often very US-oriented). But there are too many varieties of date formats out there for a general solution to be viable.
It's much easier to define a syntax for converting one input format to a wide variety of output formats than to do the converse. A syntax that is sufficiently powerful to do the job properly would end up being very similar to doing it "by hand" using the replace() function and regular expressions.
It's quite easy to DIY.
References
XSLT Date Formatting
Parsing Date/Time Information from Google XML feed using XSL Stylesheet

Raw Excel Data contains different Date formats

I have huge amounts of raw data that are separated by columns. All is well when i import these to Matlab except for the fact that I just saw that the excel files contains different formats for the dates.
One series (i.e 3 days, 1 row or each hour gets 3x24 rows) have its' dates in the format "mm/dd/yyyy" which neither excel or matlab recognizes as proper dates.
I've tried solving this problem in different ways. First i tried to just highlight the cells and use the function format cells, but this didn't work since excel doesn't see them as 'cells' but rather as 'text'.
Then i tried the Text to columns function which didn't work either (delimited or fixed width).
Im really stuck and would appreciate some help with this.
In Excel:
If cell A1 has a string like mm/dd/yyyy then try this:
=DATE(RIGHT(A1,4), LEFT(A1,2), MID(A1,4,2))
In Matlab:
=datenum(yourDateString, 'mm/dd/yyyy')
Select the desired range to fix and use this script:
Sub bulk_Date_fix()
on error resume next
Set d_ranged = Selection
For Each a In d_ranged
a.Value = Split(a.Value, "/")(0) & "/" & Split(a.Value, "/")(1) & "/" & Split(a.Value, "/")(2)
Next
on error goto 0
End Sub
How it works: The above script loops through all the cells in the selected area and splits out the various attributes of a date based on the "/" symbol.
I examined your file and you will need to go back to the source data to straighten this out. Instead of "opening" the file in Excel, you will need to IMPORT the file. When you do that, the text import wizard will open, and you can then designate the date column as being of the format DMY (or whatever format is being generated by the source).
The problem is that there is a mismatch between the format of the file, and your Windows Regional Short date format. If you look at Row 229, you will see that real dates are present, but out of sequence with the rest.
Excel parses dates being input according to the Windows Regional Short Date settings. If the date doesn't make sense, according to that parsing (e.g. month > 12) , Excel will interpret the date as a string; if the date does make sense, it will be interpreted as a date in accordance with that windows regional date component order, and this will be different from what is intended.
So the first few hundred dates are strings, but at line 229, the date, which is probably meant to be 12 OCT 2014, gets changed to 10 DEC 2014. This will happen in other areas where that value in the 2nd position is 12 or less.
EDIT: I am not certain of the variabilities inherent in using XL on the MAC. In the Windows version of XL, the "text import" feature is on the Data Ribbon / Get External Data Tab:
When you click on that and open a text file, you will see the Text Import Wizard, and when you get to Step 3, you will be able to specify the text format of the data to be imported: