JSTL cutsom date format using fmt tag [duplicate] - jstl

This question already has an answer here:
How to format date in JSTL
(1 answer)
Closed 7 years ago.
I need a date format like this.
11 November ,2015
I have tried using fmt tag.
<fmt:formatDate value="${Attr['DATE']}" type="both" dateStyle="long" />
the output is
November 11, 2015 12:00:00 AM.
How can i do that? Please help me.
Can i use any kind of pattern attribute?

Hint: fmt:formatDate has a pattern attribute too.
Try <fmt:formatDate pattern="dd M ,yyyy" value="${Attr['DATE']}" /> or <fmt:formatDate type="date" dateStyle="long" value="${Attr['DATE']}" />

Related

Calculate the difference in days between two dates using JSTL

I have set two dates using jstl. One is a current date and other is 7 days from now.
<jsp:useBean id="now" class="java.util.Date" />
<fmt:formatDate pattern="MM/dd/yyyy" value="${now}" var="nowDate"/>
<jsp:setProperty name="weekDate" property="time" value="${weekDate.time + 604800000}"/>
<fmt:formatDate pattern="MM/dd/yyyy" value="${weekDate}" var="weekDate"/>
I want to be able to find the difference between two days
I used the code shown below using code below , but
<fmt:formatDate pattern="MM/dd/yyyy" value="${(weekDate.time - nowDate.time) / (1000*60*60*24)}" var="dateDifference"/>
${dateDifference}
I get error saying
Property 'time' not found on type java.lang.String
How can I find the difference in days for the two dates?
use original objectname.time and parseNumber because we require # of days.

VBScript Convert value to Date [duplicate]

This question already has answers here:
Get dates from AUT?
(2 answers)
Closed 5 years ago.
I have a VBScript that runs on the developer machine, in which the following line of code
CDate("01/09/2017")
returns the date as 1 September 2017.
But when deployed on certain clients the same line of code returns 9 January 2017 as the date.
How can I control this?
This has been answered before in detail;
Use SetLocale() to choose how you want VBScript to interpret the value.
SetLocale(1106) 'Set to United Kingdom
WScript.Echo CDate("01/09/2017")
For valid Locale ID values see Microsoft Locale ID Values (you also appear to able to use valid IETF language tag codes as well like en-us etc).
Most likely the date string is parsed according to the regional settings of the respective system. For stable results across systems with different regional settings you probably need to parse the date yourself, e.g. like this:
s = "01/09/2017"
a = Split(s, "/")
d = DateSerial(a(2), a(1), a(0))

<c:if test=""> doesn't work [duplicate]

This question already has answers here:
jstl <c:if> tags not working in jsp file, getting error in tomcat 7
(2 answers)
Closed 5 years ago.
I'm new to JSTL and for some reason, I can't get the test line to work. Here is the simplified code I'm using:
<c:if test="${hasChild}">
test
</c:if>
when I use
${hasChild}
it prints true to the screen but it doesn't woork on the test line and I don't know why. Can anyone help please?
Have you declared hasChild prior to the test taking place? i.e.
<c:set var="hasChild">*Something which makes this value true*</c:set>
<c:if test="${hasChild}">
test
</c:if>

GO: Date and Time Parsing in GO [duplicate]

This question already has answers here:
Parsing date/time strings which are not 'standard' formats
(4 answers)
Closed 7 years ago.
I have format string "day/month/year, hour:minute:second"
How do I parse into a time object?
I tried:
const longForm = "5/01/2015, 12:00:00"
t1, _ := time.Parse(longForm, "5/01/2015, 12:00:00")
0001-01-01 00:00:00 +0000 UTC
I get some UTC time, but this is not helpful if I want to compare times because I get the same UTC time for them all. Any help?
Rule #1 of fightclub, err Go, check your errors.
That being said, the format for time parsing is defined in the documentation (scroll down to constants).
For your specific question, the format is 1/_2/2006, 15:04:05.
playground

ace:dateTimeEntry converts invalid date to its another date

I have an ace:dateTimeEntry component as below :
<ace:dateTimeEntry id="surveyDate" partialSubmit="true" renderAsPopup="true"
value="#{maintainAppointmentManagedBean.surveyNewDate}"
pattern="dd/MM/yyyy" showButtonPanel="true" navigator="true"
valueChangeListener="#{maintainAppointmentManagedBean.surveyDateChangeListener}">
</ace:dateTimeEntry>
When I manually enter an invalid date such as 21544/10/2012, icefaces converts it to some acceptable format such as 10/12/2020 or similar. It must be doing some background calculation due to which it converts the invalid date to some other date. When it reaches my own validator, the date is already converted into some other date thus my validation has no effect and no message is displayed regarding the invalid date format. There is no JIRA raised to address this. Before I raise this as a bug has anyone else faced this problem or have any solution.
Also, the problem does not occur when pattern="dd/MM/yyyy hh:mm". It occurs only when pattern is pattern="dd/MM/yyyy"
Thanks,
Dakshata Gulkhobare
I tried adding lenientParsing="false" into ace:dateTimeEntry
and it works for me.
dateTimeEntry

Resources