date-format

Java datetime format convert

≡放荡痞女 提交于 2019-11-29 15:25:33
date here my problem: String datetime = "2012-03-24 23:20:51"; I know that that string is in UTC timezone. I need to convert this string to format "yyy-mm-dd'T'HH:mm:ssZ". To do this I'm using following code: SimpleDateFormat inFormatter = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); inFormatter.setTimeZone(TimeZone.getTimeZone("UTC")); Date inDate = inFormatter.parse(datetime); SimpleDateFormat outFormatter = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ssZ"); outFormatter.setTimeZone(TimeZone.getTimeZone("UTC")); String output = outFormatter.format(inDate); The problem is that this code is

Datetime conversion error for 1 sql server, but not another

北城余情 提交于 2019-11-29 15:20:44
I've got 2 servers running SQL Server 2008, and I have the following query: SELECT cast('13/1/2011' as datetime) If I execute this query on Server A I get the result: 2011-01-13 00:00:00.000 However, if I execute this on Server B I get the result: The conversion of a varchar data type to a datetime data type resulted in an out-of-range value. I believe this to be a UK/US date format issue as I don't get an error with 12/1/2011 but it does return 2011-12-01 00:00:00.000 How can I get Server B to get the same result as Server A ? What setting needs to be changed and where? It is the language

MySQL Group By Dates Between

拈花ヽ惹草 提交于 2019-11-29 14:52:16
Is there a way to group records that fall between two dates? For example, my table has records that look like this: rid stamp uid 25 2005-07-05 14:10:29 25 1175 2005-08-12 15:47:35 29 290 2005-11-22 16:38:53 42 30 2005-12-01 10:48:12 47 30 2006-01-02 17:34:28 52 30 2006-02-06 22:11:35 57 30 2006-04-17 15:10:19 59 1195 2006-05-08 21:55:56 62 100 2006-06-30 15:51:04 94 45 2006-07-03 21:14:37 24 I'm trying to write a query that will return a count of records between the months of February - August and between September - January by year, so that what I get back is: July 2005 - January 2006: 3

How to correctly create a date with a specific format? [duplicate]

筅森魡賤 提交于 2019-11-29 13:13:16
问题 This question already has an answer here: Extract time from date String 7 answers return date type with format in java [duplicate] 1 answer I have the following doubt related how to create a format date in Java. In a Java application I have to create a date (the value have to be the current date) formatted in this way: 2015-05-26 ( yyyy-mm-dd ) So I know that I can obtain the current date simply build a new java.util.Date object, this way: Date dataDocumento = new Date(); but how can I

Formatting a String date into a different format in Java

北城余情 提交于 2019-11-29 12:57:58
I am trying to format a JSON which has a date key in the format: date: "2017-05-23T06:25:50" My current attempt is the following: private String formatDate(String date) { SimpleDateFormat format = new SimpleDateFormat("MM/DD/yyyy"); String formattedDate = ""; try { formattedDate = format.format(format.parse(String.valueOf(date))); } catch (ParseException e) { e.printStackTrace(); } return formattedDate; } But in this occasion, the result isn't shown in my app, the TextView is invisible and I couldn't log anything. I really tried other solutions, but no success for me. I don't know if it's

Format date in Java

孤者浪人 提交于 2019-11-29 11:19:22
I have the following string: Mon Sep 14 15:24:40 UTC 2009 I need to format it into a string like this: 14/9/2009 How do I do it in Java? Use SimpleDateFormat (click the javadoc link to see patterns) to parse the string in one pattern to a fullworthy Date and use another one to format the parsed Date to a string in another pattern. String string1 = "Mon Sep 14 15:24:40 UTC 2009"; Date date = new SimpleDateFormat("EEE MMM d HH:mm:ss Z yyyy").parse(string1); String string2 = new SimpleDateFormat("d/M/yyyy").format(date); System.out.println(string2); // 14/9/2009 You can use SimpleDateFormat class

Coldfusion 10 DateFormat Issue

笑着哭i 提交于 2019-11-29 08:32:18
I am using the DateFormat function to convert dates to this format: yyyy-mm-dd . This is the original format of the date: dd-mm-yyyy . Below is a snippet of the code: <cfset newdate = #DateFormat(Trim(mydate), "yyyy-mm-dd")# /> The problem is that I get different results for different dates. For example: If my original date is: 15-05-2013 ( dd-mm-yyyy ) The result is: 2013-05-15 ( yyyy-mm-dd ) However, if I change the input and: The original date is: 01-05-2013 ( dd-mm-yyyy ) The result is: 2013-01-05 ( yyyy-dd-mm ) Any help or guidance as to what is wrong would be highly appreciated. I

DateFormat conversion problem in java?

孤人 提交于 2019-11-29 08:19:59
my input String is : 2010-03-24T17:28:50.000Z output pattern is like: DateFormat formatter1 = new SimpleDateFormat("EEE. MMM. d. yyyy"); i convert this like this: formatter1.format(new Date("2010-03-24T17:28:50.000Z"));//illegalArgumentException here the string "2010-03-24T17:28:50.000Z" ouput should be like this: Thu. Mar. 24. 2010 idea but i get a illegalArgumentException . Dont know why? any idea?? stacktrace message is: 04-08 19:50:28.326: WARN/System.err(306): java.lang.IllegalArgumentException 04-08 19:50:28.345: WARN/System.err(306): at java.util.Date.parse(Date.java:447) 04-08 19:50:28

How to get a particular date format ('dd-MMM-yyyy') in SELECT query SQL Server 2008 R2

不打扰是莪最后的温柔 提交于 2019-11-29 07:30:33
问题 I am using CONVERT(data_type(length),expression,style) function to change the format of a date in a SELECT query. Declare @dt nvarchar(20) Select @dt = Convert(nvarchar(20), SalesDate, 113) FROM SalesTable The format I need is 'dd-MMM-yyyy' (eg. '05-Jul-2013') but I could not find the proper style number (eg. 113) for this particular format. Can any one help me with that please? 回答1: Try this: Declare @dt NVARCHAR(20) Select @dt = REPLACE(CONVERT(CHAR(15), SalesDate, 106),' ',' - ') FROM

If-Modified-Since Date Format

牧云@^-^@ 提交于 2019-11-29 06:45:36
I am now writing a server and I would like to check for "If-Modified-Since: " header. Since there are so many date methods, which methods should I consider to check, like a usual method (milliseconds is used in browsers).... Follwing is howi did for milliseconds format. Date date; //dateS is a substring of If-Modified-Since: header try{ long mills = Long.parseLong(dateS); } catch (NumberFormatException e) {e.printStackTrace(); } date = new Date(mills); I also want to check for "Wed, 19 Oct 2005 10:50:00 GMT" format. How can I change that date into milliseconds ?? SimpleDateFormat dateFormat =