Convert a date in string YYYY-MM-DD to MM/DD in JSTL [duplicate] - date

This question already has answers here:
Convert and format a Date in JSP
(6 answers)
Closed 5 years ago.
I have a string field that is shown as a date in YYYY-MM-DD format. I am trying to convert this field on my JSP to MM/DD date format. Here is the JSTL code I have now:
<fmt:parseDate var="taxFromDate" value="${a8spt214.fromDate}" pattern="MM-dd"/>
<fmt:parseDate var="taxToDate" value="${a8spt214.toDate}" pattern="MM-dd"/>
When I try running this I get a compile error saying the following
In <parseDate>, value attribute can not be parsed: "2017-06-30"] with root cause java.text.ParseException: Unparseable date: "2017-06-30"
is it possible to convert a string to a date filed in JSP without actually using the year in the format? Or is the pattern invalid?
Thanks

You can use this Code to show this type of date MM/DD/YY
<p>Formatted Date : <fmt:formatDate type = "both"
dateStyle = "short" timeStyle = "short" value = "${now}" /></p>
The Code above will Print this result:
Formatted Date : 23/09/10 14:27
I hope to help you solve problem.

Related

Invalid date format [Flutter] [duplicate]

This question already has answers here:
How do I convert a date/time string to a DateTime object in Dart?
(8 answers)
Closed 9 months ago.
I've been trying convert a String to DateTime in dart using DateTime.parse(dateStart), where 'dateStart' is my variable that I use to get the date, for example in the next format '24/12/2022', but I catch invalid date format, I would like to known which are the validates formats to use in dart.
DateTime.parse(dateStart)
You need to use intl package to parse string date to datetime object. Please check sample Datetime parse example as below.
DateTime tempDate = new DateFormat("dd/MM/yyyy").parse(savedDateString);
You can format '24/12/2022' to DateTime like this:
final dateTime = DateFormat('dd/MM/yyyy').parse('24/12/2022');

What type of date string is this? `20210713T015433.354Z` [duplicate]

This question already has answers here:
What is this date format? 2011-08-12T20:17:46.384Z
(11 answers)
Closed 1 year ago.
I'm working with some data where I don't know how the time string was generated but an example of what the date string looks like is this 20210713T015433.354Z
I've looked at some examples of date strings (ex1 and ex2) but haven't had any luck decoding it.
I know that the first half of the string is YYYYMMDD, and then I think that T means times but then I don't know what 015433.354Z is.
My eventual goal is to make this into a Date objects in JS but I can't deduce the formatting. beyond the day it occured.
The date format provided is ISO 8601. Maybe you want to try the following to get a Date object:
new Date(Date.UTC(2021, 7, 13, 1, 54, 33, 354))
As pointed in this SO answer.

Converting number of years to date using dart

I've been trying to convert number of years to date using dart. The format has to be YYYY-MM-DD. There is 19 years for example and I'm trying to get 2001-02-12 programmatically.
I've also tried looking for a library here but I can't find any that can help me In this case. Thank you.
for date format you can use DateFormatter fomatter = 'yyyy-MM-dd'; , DateTime date = DateTime(year: year); to create the date with the correct year. Then you can format the date. String formattedDate = formatter.format(date);.
Choose appropriate string format value for formatter and type for formattedDate and done.
Cheers

How to split Japanese Date which include month and year into or Date format [duplicate]

This question already has answers here:
How does Java "week year" really work?
(2 answers)
Why I get a wrong result when parsing a date from string with SimpleDateFormat ? (Java) [duplicate]
(1 answer)
java parsing string to date
(2 answers)
Is SimpleDateFormat in Java work incorrect or I did any mistake? See code sample [duplicate]
(2 answers)
Closed 2 years ago.
I want to split Japanese date which is in format "2020年7月" into separate array so that can get the year and month from that.
I tried SimpleDateFormatter to format Japanese date with and have the year and date separated with "/"but the output is wrong:
Tried this code:
val inputFormat = SimpleDateFormat("YYYY年M月")
val date = inputFormat.parse("2020年7月")
val outputText = SimpleDateFormat("YYYY/MM").format(date)
input :2020年7月
output:2020/12
Can anyone help me in this?
You should be using java.time for this because the datetime classes from java.util are outdated (but still not deprecated).
The following example shows a way using a java.time.format.DateTimeFormatter for parsing a String formatted according to a certain pattern and a java.time.YearMonth, a class obviously designed for the purpose of creating a month in a year without respect to a day of month:
import java.time.YearMonth;
import java.time.format.DateTimeFormatter;
fun main() {
val jpYearMonth = "2020年7月"
val japaneseDtf = DateTimeFormatter.ofPattern("uuuu年M月")
val yearMonth = YearMonth.parse(jpYearMonth, japaneseDtf)
println(yearMonth.format(DateTimeFormatter.ofPattern("uuuu/MM")))
}
In order to achieve your desired output this code has to use a different DateTimeFormatter defining the output pattern because the default pattern (internal use when you just println(yearMonth)) would be hyphon-separated (2020-07):
2020/07

converting a utc format date string to date object in Extjs

I have a date string in the format "2013-01-31T10:10:05.000Z". I want to convert this string to a Date object in extjs.
I have tried to use Ext.Date.parse("2013-01-31T10:10:05.000Z","Y-m-dTH:i:s.uZ"). But it is returning undefined.
I also tried with new Date("2013-01-31T10:10:05.000Z"), but it is also returning undefined.
Note: I have tried in IE8 browser.
Could anyone please help me to convert the above date string to Date object?
Thanks a lot sra. Now I am getting the result as ...UTC+5:30... Is there any way to convert this in IST format?
Try Ext.Date.parse("2013-01-31T10:10:05.000Z","c");
The c is the format type for ISO 8601 formatted dates
See the Ext.Date API for more details on this or other available formats
That's because 'T' and 'Z' are special characters in the Date format: http://docs.sencha.com/extjs/4.2.1/#!/api/Ext.Date
You have to escape them like this: Ext.Date.parse("2013-01-31T10:10:05.000Z","Y-m-d\\TH:i:s.u\\Z")