convert date to xml type date ('YYYY-MM-DD"T"HH24:MI:SS) - date

the user enters date in mm-dd-yy format. I have to convert this into ('YYYY-MM-DD"T"HH24:MI:SS) how can i do this in vb.net
Thanks

use DateTime Parse or ParseExact methods (or their Try... variation)
then ToString with your format string the resulting value if it is valid, otherwise tell user to enter a better value.
I don't actually speak VBian so I can't provide sample code.

Related

Matlab - isbusday and busdate format change

Would you be able to advise how can i change the format of the date the functions isbusday and busdate are using ?
The functions use US date format by default, but I need them to be in European format dd/mm/yyyy.
I have attempted to use the code below but it is not working.
isbusday('01-01-2015','dd-mm-yyyy')
busdate('01-01-2015','dd-mm-yyyy',1)
Thank you very much.
You want to convert your string to a datetime object. That is where you can control the format:
d = datetime('01-01-2015','InputFormat','dd-mm-yyyy');
isbusday(d)
busdate(t)
See the documentation: https://www.mathworks.com/help/matlab/ref/datetime.html and https://www.mathworks.com/help/finance/isbusday.html

using DateFormat to produce a "2016-12-28T17:43:47.345Z"

I have been looking at the above question and have most of it correct.
I am going to get a datetime in Zulu, and then will want to output that format.
My first go is just as simple as:
DateFormat format = new DateFormat("yyyy-MM-dd'T'HH:mm:ss.SSS'Z'");
My issue I am having is the T and Z. Obviously T is used to separate the date from the time and the Z is representative of Zulu time.
That being said the users will be entering a datetime in Zulu, so it wont need to be converted from Local to Zulu, so i was not sure if 'Z' is an acceptable result. I was not sure if there is a different want to handle this, or if my result was the best answer.
Try this package, Jiffy.
String isoFomart = Jiffy().format(); // This will return ISO format from now
You can also add your DateTime object
String isoFomart = Jiffy(DateTime.now()).format(); // This will also return ISO format from now
Hope this helped
The DateTime object has a method called: toIso8601String which is used to return an ISO formatted string. The 'Z' will be added if isUTC is true, otherwise the result will not have the Z in it.
Make sure that the DateTime object itself is correctly set to UTC as if you look in the constructor for the class will tell you a lot of the defaults are local with the exception of the DateTime.utc() static function.
In that concept, you dont really need a DateFormat use to define an iso string.

Get a DateTime with an specific pattern with nscala-time

I am trying to get this pattern 'dd-MM-yyyy' with a variable of type DateTime
#{DateTimeFormat.forPattern("dd-MM-YYYY").parseDateTime(user.birthday.toString)}
But I am getting this error
java.lang.IllegalArgumentException: Invalid format: "2015-12-10T00:00:00.000Z" is malformed at "15-12-10T00:00:00.000Z"
Is there a way to do this with nscala-time?
makes a difference if I am using UTC?
UPDATE
For the moment I am casting to Date and doing this
#{Dates.format(user.birthday.toDate, "dd-MM-YYYY")}
But maybe is a better way without casting
thank you
So, if I understood your question correctly, you are trying to achieve the following:
Parse date from a string using a date format
Print/Display the date in another format.
Try the below:
#{Dates.format(DateTimeFormat.forPattern("yyyy-MM-dd'T'HH:mm:ss.SSSZ").parseDateTime(user.birthday.toString), "dd-MM-YYYY")}

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")

Parsing String to Date during internationalization in gwt

i am try to parse string to date it works normally well but when i am use internationalization with &locate=fr then it will thrown java.lang.IllegalArgumentException.
hear is the peace of code i want to get date from string.
public static Date toDate(String date){
DateTimeFormat format = DateTimeFormat.getFormat("MM/dd/yy h:mm:s a");
return format.parseStrict(date);
}
and i am try to convert "02/02/2012 10:10:25 AM".
please help me.
Try using parse() instead of parseStrict(). If you use parse() dates are parsed leniently, so invalid dates will be wrapped around as needed. And with parseStrict() dates are parsed strictly, so invalid dates will result in an IllegalArgumentException. See you are using different format for your date.
02/02/2012 which corresponds to MM/dd/yyyy not to MM/dd/yy
public Date parseStrict(java.lang.String text) throws java.lang.IllegalArgumentException
Parses text to produce a Date value. An IllegalArgumentException is
thrown if either the text is empty or if the parse does not consume
all characters of the text. Dates are parsed strictly, so invalid
dates will result in an IllegalArgumentException.
instead of standard DateTimeformat use com.google.gwt.i18n.client.DateTimeFormat