date-format

What string date format will javascript's parse recognize?

一个人想着一个人 提交于 2020-01-13 02:13:06
问题 i know when constructing a Date object in javascript with a dateString parameter, the string must be something that parse() can recognize. What date format can parse recognize? For example: var postDate = new Date("2011-03-08T23:52:38"); works in Chrome and Internet Explorer, but fails on an iPhone (returns Jan 1, 1970). i cannot find any formal documentation on the .parse() method, or the constructor, about what the parameter should be. The format yyyy-mm-ddThh:nn:ss doesn't work. What is

How can I convert this date in Java?

你说的曾经没有我的故事 提交于 2020-01-10 05:34:19
问题 I want to convert: 2010-03-15T16:34:46Z into something like "5 hours ago" How can I do this in Java? 回答1: JodaTime supports parsing from a user-defined format. See DateTimeFormatterBuilder and DateTimeBuilder.parseDateTime(). Once you have a DateTime, you can create a Duration or Period from that and the current time, and use another formatter to pretty-print. [See the PeriodFormatter example referenced by BalusC in comments above.] 回答2: I know a plugin in Jquery for this : http://plugins

Going from MM/DD/YYYY to DD-MMM-YYYY in java

我的未来我决定 提交于 2020-01-10 01:25:09
问题 Is there a method in Java that I can use to convert MM/DD/YYYY to DD-MMM-YYYY ? For example: 05/01/1999 to 01-MAY-99 Thanks! 回答1: Use a SimpleDateFormat to parse the date and then print it out with a SimpleDateFormat withe the desired format. Here's some code: SimpleDateFormat format1 = new SimpleDateFormat("MM/dd/yyyy"); SimpleDateFormat format2 = new SimpleDateFormat("dd-MMM-yy"); Date date = format1.parse("05/01/1999"); System.out.println(format2.format(date)); Output: 01-May-99 回答2: Try

mysql date comparison with date_format

对着背影说爱祢 提交于 2020-01-09 02:25:43
问题 I googled and tried several ways to compare date but unfortunately didn't get the result as expected. I have current state of records like following: mysql> select date_format(date(starttime),'%d-%m-%Y') from data; +-----------------------------------------+ | date_format(date(starttime),'%d-%m-%Y') | +-----------------------------------------+ | 28-10-2012 | | 02-11-2012 | | 02-11-2012 | | 02-11-2012 | | 03-11-2012 | | 03-11-2012 | | 07-11-2012 | | 07-11-2012 | I would like to compare date

Java determine one dateformat from several dateformats

泪湿孤枕 提交于 2020-01-06 12:55:49
问题 We want to get a correct dateformat from LOG files generated by different systems with different language and log mechanism. We thought this can be done be a SimpleDataFormat.parse and try-catch exception way. But the follow code shows a problem. String tryparseString = "18-01-22 00:03:34:071"; try { SimpleDateFormat sdf1 = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); System.out.println(sdf1.parse(tryparseString)); System.out.println(sdf1.format(sdf1.parse(tryparseString))); System.out

Unit Test - Simple assert is giving null pointer exception error [duplicate]

て烟熏妆下的殇ゞ 提交于 2020-01-06 05:33:28
问题 This question already has answers here : What is a NullPointerException, and how do I fix it? (12 answers) Closed 11 months ago . I am writing a unit test to verify that both the ISO8601Utils (deprecated class which I replaced with SimpleDateFormat) and SimpleDateFormat has the same format. My class: public static class ISO8601DateFormat extends DateFormat { public static final long serialVersionUID = 3549786448500970210L; public ISO8601DateFormat() {} @Override public StringBuffer format

How can I change more than a date format in a unique format with a single php function?

我们两清 提交于 2020-01-06 03:16:26
问题 I would like to understand how to change different date formats into a single format using a php function. After trying in every way, i wasn't able to solve this puzzle. I always just used the following code in my custom function.php smoothly: /* Change date format for coupon */ function change_date_format($x) { $date = DateTime::createFromFormat('j-M-Y', $x); $x = $date->format('Y-m-d'); return $x; } In this way i can convert the format 'j-M-Y' in the format 'Y-m-d'. The problem is that now

ODBC linked table not showing fractions of seconds

夙愿已清 提交于 2020-01-05 10:18:47
问题 I have linked an IBM informix database table through an ODBC connection to an Access 2010 database. My issue is that the date field in this table only shows dd/mm/yy HH:nn:ss in the Access view, where the stored data is to 1000th of a second. I can show this in Excel 2010 but not in Access 2010: is this possible? Not having this level of accuracy is preventing me making accurate calculations! 回答1: There is a similar question on another forum here. The Date/Time field type in Access does not

AM/PM DateFormat substitution at TimePickerDialog

社会主义新天地 提交于 2020-01-05 08:03:55
问题 I have some layout/button and onClick I get TimePickerDialog with current time (previously defined from Calendar ): RelativeLayout time = (RelativeLayout) findViewById(R.id.time_layout); time.setOnClickListener(new View.OnClickListener() { public void onClick(View arg0) { TimePickerDialog dateDialog = new TimePickerDialog(SelectDateTimeActivity.this, TimeSetListener, hours, minutes, false); dateDialog.show(); } }); TimePicker is in 12h mode - it has AM/PM mark. TimeSetListener looks like

How to check if String contains a only Date format in Java?

扶醉桌前 提交于 2020-01-05 08:03:49
问题 How to find a String contains fully on date formats, not an check with single date format, I want to check string with various formats? If a string matches with various formats means return boolean value. Is that possible to use a Date array? This is the sample line of code: Date[] dates = {"12/09/2014","2014/09/09"....}; 回答1: Date d=new Date(); System.out.println("DATE :"+ new SimpleDateFormat("dd.M.yyyy").format(d)); System.out.println("DATE :"+ new SimpleDateFormat("M/dd/yyyy").format(d));