datetime-format

ObjectDataSource fails to parse string to DateTime

北慕城南 提交于 2019-12-01 20:57:56
I have a textbox with value that stores ValidFrom form value: 31.01.2012 and cultures set to: <globalization culture="en-GB" uiCulture="en-GB"/> in web.config. And now, ObjectDataSource update method: public static void UpdateLac(int id, DateTime ValidFrom) { /// ... } fails as I get exception that string cannot be parsed. However date in format dd.mm.yyyy ( 31.01.2012 ) is valid en-GB format and can be parsed (as far as I know). I have tested it with following code: DateTimeFormatInfo dtfi = CultureInfo.CreateSpecificCulture("en-GB").DateTimeFormat; var date = DateTime.Parse("31.01.2012",

java.time.format.DateTimeParseException: Text 'Mi Mai 09 09:17:24 2018' could not be parsed at index 0

假装没事ソ 提交于 2019-12-01 20:53:59
I'm trying to format a date time object with a german locale but i got an error. String dateString = "Mi Mai 09 09:17:24 2018"; DateTimeFormatter dtf = DateTimeFormatter.ofPattern("EE MMM dd HH:mm:ss yyyy", Locale.GERMAN); LocalDateTime dateTime = LocalDateTime.parse(dateString, dtf); The error: java.time.format.DateTimeParseException: Text 'Mi Mai 09 09:17:24 2018' could not be parsed at index 0 Solution here and now: System.setProperty("java.locale.providers", "COMPAT,CLDR"); String dateString = "Mi Mai 09 09:17:24 2018"; DateTimeFormatter dtf = DateTimeFormatter.ofPattern("EE MMM dd HH:mm

Date/Time Conversion ColdFusion

白昼怎懂夜的黑 提交于 2019-12-01 18:51:37
I'm working with a script that displays the date and time in ISO 8601 format like so: 2012-05-17T17:35:44.000Z . but I would like it to display in the normal ColdFusion timestamp format when using the #Now()# notation ... so in this format: {ts '2012-05-17 17:35:44'} How can I do this? As of CF 10, ISO-8601 is supported directly by parseDateTime . <cfset string = "1997-07-16T19:20:30+01:00"> <cfset date = parseDateTime(string, "yyyy-MM-dd'T'HH:mm:ssX")> Runnable Example on TryCF.com Pretty sure just a parse and then output will give it to you in the format you want : #parseDateTime(REReplace(

DateTime.Parse throwing format exception

走远了吗. 提交于 2019-12-01 17:48:27
问题 I retrieve date and time strings from xml by parsing XElement. The date and time values are retrieved by file.Element("Date").Value and file.Element("Time").Value respectively. After I retrieve the Date value I parse it to a DateTime variable DateTime dt,ts; dt = file.Element("Date").Value; // the value is say 12/29/2012 and then this dt value is set to a datepicker value on the xaml UI datepicker.Value = dt; I also have a timepicker whose value have to be set by the Time value retrieved from

Issue DateTime.ToString with string format “M” in .NET

寵の児 提交于 2019-12-01 15:26:21
I have a problem with the string format of DateTime. I think it is bug in MS. Can you explain it, and what is wrong? class Program { static void Main(string[] args) { Console.WriteLine(DateTime.Now.ToString("M"));//return 07 July <---- WRONG, SEE MSDN Console.WriteLine(DateTime.Now.ToString(".M"));//return .7 <---- GOOD Console.ReadKey(); } } MSDN From The "M" Custom Format Specifier If the "M" format specifier is used without other custom format specifiers , it is interpreted as the "M" standard date and time format specifier . For more information about using a single format specifier, see

Convert timestamp/date time from UTC to EST Oracle SQL

柔情痞子 提交于 2019-12-01 15:07:30
I have a field with a date/time value like this: 2009-11-17 18:40:05 It's in UTC. In the query how can I convert this to EST? I'm trying something like this but it throws an error. // datetime is the field name SELECT FROM_TZ(TIMESTAMP TO_DATE(datetime, 'yyyy-mm-dd hh24miss'), 'EST') AS DT FROM db_name I had to tweak it slightly to get it to work on my database, but this worked: select from_tz(to_timestamp('2009-11-17 18:40:05','yyyy-mm-dd hh24:mi:ss'), 'UTC') at time zone 'America/New_York' from dual The key is the "at time zone" syntax. If you want to convert a date field from UTC to EST,

How to parse date format?

℡╲_俬逩灬. 提交于 2019-12-01 14:51:11
In one of the webservices my application is consuming, I encountered the following DateTime format. "/Date(1395780377459)/" Is this some standard date format? If so, how to parse this into DateTime object? EDIT: Thanks for the comments. So "/Date(1395780377459)/" corresponds to GMT: Tue, 25 Mar 2014 20:46:17 GMT . I was wondering how to parse this in .net. Tried: string test = "/Date(1395780377459)/"; var datestring = test.Substring(6).TrimEnd(')','/'); var date = new DateTime(long.Parse(datestring)); Tried this too: string test = "/Date(1395780377459)/"; var datestring = test.Substring(6)

Conversion of Python DateTime string into integer milliseconds

雨燕双飞 提交于 2019-12-01 14:22:27
I would like to convert a UTC TimeDate stamp string into an integer value of milliseconds (might need to be a 64-bit quantity), so that it takes up less space when stored in a mySQL database column. This UTC string is being generated from another library, and I store it as a kind of per-user GUID. Can datetime or dateutil convert this into a single integer value (like "milliseconds since epoch")? Or do I need to do that myself? Parsing using this approach: myDateTime = dateutil.parser.parse("2015-06-27T02:10:05.653000Z") print("Parsed datetime String is {0}, ordinal value is {1}".format

Remove hours:seconds:milliseconds in DateTime object

人走茶凉 提交于 2019-12-01 14:00:41
问题 I'm trying to create a string from the DateTime object which yields the format mm:dd:yyyy . Conventionally the DateTime object comes as mm:dd:yyyy hrs:min:sec AM/PM . Is there a way to quickly remove the hrs:min:sec AM/PM portion of the DateTime so that when I convert it ToString() it will only result in mm:dd:yyyy ? 回答1: To answer your question, no - you would have to store it in a different type. The most simple choice is to use a string. string date = dateTime.ToString("MM:dd:yyyy");

Conversion of Python DateTime string into integer milliseconds

老子叫甜甜 提交于 2019-12-01 12:56:35
问题 I would like to convert a UTC TimeDate stamp string into an integer value of milliseconds (might need to be a 64-bit quantity), so that it takes up less space when stored in a mySQL database column. This UTC string is being generated from another library, and I store it as a kind of per-user GUID. Can datetime or dateutil convert this into a single integer value (like "milliseconds since epoch")? Or do I need to do that myself? Parsing using this approach: myDateTime = dateutil.parser.parse(