date-conversion

Convert Json date to java calendar

让人想犯罪 __ 提交于 2019-12-01 11:21:16
I have the following value /Date(1234043600000)/ in string type and I need to convert it to java calendar type without a success,I have tried to use the following post and create date and than do something like the post How do I format a Microsoft JSON date? Date date = new Date(parseInt(jsonDate.substr(6))); and than do someting like Calendar cal = Calendar.getInstance(); cal.setTime(date); I got error in the first line since in the word date i have line in the middle and substr(6) have error (The method substr(int) is undefined for the type String) ,how should I continue . Thanks! This

Conversion failed when converting date and/or time from character string in SQL SERVER 2008

淺唱寂寞╮ 提交于 2019-12-01 05:44:30
I have below SQL. UPDATE student_queues SET Deleted=0, last_accessed_by='raja', last_accessed_on=CONVERT(VARCHAR(24),'23-07-2014 09:37:00',113) WHERE std_id IN ('2144-384-11564') AND reject_details='REJECT' when I ran the above SQL the below exception has been throwed. Conversion failed when converting date and/or time from character string. If you're trying to insert in to last_accessed_on , which is a DateTime2 , then your issue is with the fact that you are converting it to a varchar in a format that SQL doesn't understand. If you modify your code to this, it should work, note the format of

Date Conversion with ThreadLocal

安稳与你 提交于 2019-12-01 03:57:31
I have a requirement to convert incoming date string format "20130212" (YYYYMMDD) to 12/02/2013 (DD/MM/YYYY) using ThreadLocal . I know a way to do this without the ThreadLocal . Can anyone help me? Conversion without ThreadLocal : final SimpleDateFormat format2 = new SimpleDateFormat("MM/dd/yyyy"); final SimpleDateFormat format1 = new SimpleDateFormat("yyyyMMdd"); final Date date = format1.parse(tradeDate); final Date formattedDate = format2.parse(format2.format(date)); ThreadLocal in Java is a way to achieve thread-safety apart from writing immutable classes. Since SimpleDateFormat is not

Convert string with different format to date

試著忘記壹切 提交于 2019-12-01 00:43:37
I have a table with a string column ( varchar(200) ) that contain a date in different format. For example may 24 1983 12:00AM 1981-01-13 00:00:00 1979-01-13 00:00:00:123 I want to convert this column in a date to extract year. How could i do? I have used STR_TO_DATE but don't work well. I must use SUBSTRING for each different format? MySQL version 5.0.95 There's a trick for detecting a valid date on the man page . You can use it to determine whether a STR_TO_DATE format worked. select foo, case when length(date(str_to_date(foo,"%Y-%m-%d %H:%i:%S"))) is not null then str_to_date(foo,"%Y-%m-%d

Date Conversion with ThreadLocal

吃可爱长大的小学妹 提交于 2019-12-01 00:40:19
问题 I have a requirement to convert incoming date string format "20130212" (YYYYMMDD) to 12/02/2013 (DD/MM/YYYY) using ThreadLocal . I know a way to do this without the ThreadLocal . Can anyone help me? Conversion without ThreadLocal : final SimpleDateFormat format2 = new SimpleDateFormat("MM/dd/yyyy"); final SimpleDateFormat format1 = new SimpleDateFormat("yyyyMMdd"); final Date date = format1.parse(tradeDate); final Date formattedDate = format2.parse(format2.format(date)); 回答1: ThreadLocal in

SQL date format conversion from INT(yyyymmdd) type to date(mm/dd/yyyy)

好久不见. 提交于 2019-11-30 21:40:13
I have a table with datekey column values(20120728,20120728...) in format of yyyymmdd as int type, I need to make them into date format of mm/dd/yyyy while writing select statement. DECLARE @date int; SET @date = 20131107 SELECT CONVERT(date, CONVERT(varchar(8), @date), 112) Please Try This DECLARE @date int; SET @date = 20120728 SELECT CONVERT(varchar(20), CONVERT(date, CONVERT(varchar(8), @date), 112),110)as datetime 来源: https://stackoverflow.com/questions/19829818/sql-date-format-conversion-from-intyyyymmdd-type-to-datemm-dd-yyyy

Convert string with different format to date

北城以北 提交于 2019-11-30 18:11:17
问题 I have a table with a string column ( varchar(200) ) that contain a date in different format. For example may 24 1983 12:00AM 1981-01-13 00:00:00 1979-01-13 00:00:00:123 I want to convert this column in a date to extract year. How could i do? I have used STR_TO_DATE but don't work well. I must use SUBSTRING for each different format? MySQL version 5.0.95 回答1: There's a trick for detecting a valid date on the man page. You can use it to determine whether a STR_TO_DATE format worked. select foo

Converting an 8-digit integer into dd/mm/yyyy [duplicate]

旧时模样 提交于 2019-11-30 18:07:50
问题 This question already has answers here : Convert one date format into another in PHP (15 answers) Closed 5 years ago . So i have this function in my PHP script that is supposed to take the date as an 8-digit integer such as 01042012 and convert it to 01/04/2012 for displaying. Currently i'm trying to use php's date() function as follows: $int = 01042012; $date = date("d/m/Y", $int); Instead of $date having the value 01/04/2012 it shows as 13/01/1970 . Is this because date() wants the date i

How can I convert a date in Epoch to “Y-m-d H:i:s” in Javascript?

邮差的信 提交于 2019-11-30 17:35:13
How can I convert following date in epoch: 1293683278 to following readable date: 2010-06-23 09:57:58 using Javascript? Thanks! deadrunk var timestamp = 1293683278; var date = new Date(timestamp * 1000); var year = date.getFullYear(); var month = date.getMonth() + 1; var day = date.getDate(); var hours = date.getHours(); var minutes = date.getMinutes(); var seconds = date.getSeconds(); console.log(year + "-" + month + "-" + day + " " + hours + ":" + minutes + ":" + seconds); See js Date docs for further details Another way: var timestamp = 1293683278; var date = new Date(timestamp * 1000); var

How convert Gregorian date to Persian date?

本小妞迷上赌 提交于 2019-11-30 06:04:58
I want to convert a custom Gregorian date to Persian date in C#. For example, i have a string with this contents: string GregorianDate = "Thursday, October 24, 2013"; Now i want to have: string PersianDate = پنج‌شنبه 2 آبان 1392 ; or string PersianDate = 1392/08/02 Thanks Use the PersianCalendar: string GregorianDate = "Thursday, October 24, 2013"; DateTime d = DateTime.Parse(GregorianDate); PersianCalendar pc = new PersianCalendar(); Console.WriteLine(string.Format("{0}/{1}/{2}", pc.GetYear(d), pc.GetMonth(d), pc.GetDayOfMonth(d))); You can use PersianDateTime: PM> Install-Package