date-format

Why Does Java's SimpleDateFormat parse this

蓝咒 提交于 2019-12-04 00:17:39
问题 Hi I've got a simple date format set up with a custom format string: MMddyy and I give it the following value to parse: 4 1 01 I don't think it should parse this because of the spaces but the Simple Date Format is returning the date April 4th 0001AD any ideas why? 回答1: This is expected behaviour - you are telling the DateFormat object to expect a 6 character String representation of a date and that is what you passed in. Spaces are parsed OK. However, if you used "4x1x01" you would get an

How to round a Pandas `DatetimeIndex`?

会有一股神秘感。 提交于 2019-12-03 23:58:22
问题 I have a pandas.DatetimeIndex , e.g.: pd.date_range('2012-1-1 02:03:04.000',periods=3,freq='1ms') >>> [2012-01-01 02:03:04, ..., 2012-01-01 02:03:04.002000] I would like to round the dates ( Timestamp s) to the nearest second. How do I do that? The expected result is similar to: [2012-01-01 02:03:04.000000, ..., 2012-01-01 02:03:04.000000] Is it possible to accomplish this by rounding a Numpy datetime64[ns] to seconds without changing the dtype [ns] ? np.array(['2012-01-02 00:00:00.001']

System date formatting not using django locale

烂漫一生 提交于 2019-12-03 23:38:05
Trying to understand L10N implementation into Django, Here are my settings LANGUAGE_CODE = 'fr-FR' USE_L10N = True If I try >>> datetime.datetime.strptime('2012-05-30 15:30', '%Y-%m-%d %H:%M') .strftime('%c') It will give me 'Wed May 30 15:30:00 2012' that is the EN locale. However the doc is saying: [...] Two users accessing the same content, but in different language, will see date and number fields formatted in different ways, depending on the format for their current locale [...] Are they talking about the locale set for their respective browser ? If not, how can I set it to french by

How to make fmt:formatDate work for form:input

无人久伴 提交于 2019-12-03 23:29:01
I have a jstl loop and I want to format the date of a form:input. I have tried many permutations of some of the suggestions that I've fond online but I just cannot get it to work.. Can someone please have a look? I've included the full loop for context but the problem lies in the last <td></td> block. <c:forEach items="${valueTransactionsModel.transactions}" var="transaction" varStatus="loopStatus"> <tr class="${loopStatus.index % 2 == 0 ? 'even' : 'odd'}"> <spring:message code="valueTransactions.transactionType" var="transactionTypeLbl" /> <tags:dropdown id="transactionTypeId${loopStatus

Failed to convert property value of type java.lang.String to required type java.util.Date

给你一囗甜甜゛ 提交于 2019-12-03 23:10:42
I'm getting this error when I try to input a date in a form. TaskController @RequestMapping(value = "/docreatetask", method = RequestMethod.POST) public String doCreateTask(Model model, @Valid Task task, BindingResult result, Principal principal, @RequestParam(value = "delete", required = false) String delete) { System.out.println(">TaskController doCreateTask " + task); if (result.hasErrors()) { System.out.println("/docreatetask in here"); model.addAttribute("task", task); System.out.println("+++++"+task.getDeadline());// deadline is null return "createtask"; } ... Create.jsp ... <form:form

Displaying proper date format depending on culture

你。 提交于 2019-12-03 21:06:10
问题 I am using a control for a popup calendar date picker. This uses a javascript function, SetText, to set the textbox to the given date. I can't change anything in the calendar control itself but I can override the SetText function. The SetText javascript just takes the TextBox name and the date value in string format and sets the TextBox to the string. The problem: I need to display the date in the format "April 30". Easy to do. Use getMonth() and getDate() where I can parse the information

Wrong DateFormat with Jquery Datepicker

三世轮回 提交于 2019-12-03 18:12:18
问题 I want to exclude the time part in the DateTime Textbox, but I can't make it work the way I want. This is how I set up the field : @Html.TextBoxFor(m => m.DateFrom, "{0:dd/MM/yyyy}", new { @class = "datefrom" }) @Html.TextBoxFor(m => m.DateTo, "{0:dd/MM/yyyy}", new { @class = "dateto" }) Jquery script: $(function () { $(".datefrom").datepicker({ defaultDate: "+1w", changeMonth: true, numberOfMonths: 1, dateFormat: "dd/mm/yy", onClose: function (selectedDate) { $("#to").datepicker("option",

Format a date from inside a Handlebars Template in Meteor

眉间皱痕 提交于 2019-12-03 17:54:00
问题 I got a ISO formatted Date from my Data and what I actually want to do, is to modify my date format directly from my Templates. like this: {{format my.context.date "myFormat"}} I'm using the moment library, so I could write something like this: {{formatDate my.context.date "DD.MM.YYYY HH:mm"}} // 03.09.2013 18:12 It would be nice, because I think it's the place where I should be able to do this. In my template. 回答1: The solution is quite simple, and maybe someone will find it useful. In most

How to get yesterday date in node.js backend?

走远了吗. 提交于 2019-12-03 16:15:11
I am using date-format package in node back end and I can get today date using var today = dateFormat(new Date()); In the same or some other way I want yesterday date. Still I did't get any proper method. For the time being I am calculating yesterday date manually with lot of code. Is there any other method other then writing manually ? Try this: var d = new Date(); // Today! d.setDate(d.getDate() - 1); // Yesterday! I would take a look at moment.js if you are interested in doing calculations with dates, there are many issues you can run into trying to do it manually or even with the built in

How does Date.toLocaleDateString() work?

走远了吗. 提交于 2019-12-03 15:30:32
I've to represent the date with local user's configurations. Follows the MDN description: The toLocaleDateString method relies on the underlying operating system in formatting dates. It converts the date to a string using the formatting convention of the operating system where the script is running. For example, in the United States, the month appears before the date (04/15/98), whereas in Germany the date appears before the month (15.04.98). I do this: var date = new Date (); console.log (date.toLocaleDateString ()); It prints out Saturday, October 13, 2012 but what I expect is Sabato, 13