date-formatting

Why there is need to add 1 to the month for this date conversion?

放肆的年华 提交于 2019-12-02 10:52:32
I have this date variable in javascript $scope.dt and the contents is Tue Jul 08 2014 00:00:00 GMT+0800 (Malay Peninsula Standard Time) . I want to convert it to return a string that is 2014-7-8 (YYYY-MM-DD). Below is the function I wrote; function convertDate_YYYYMMDD(d) { var curr_date = d.getDate(); var curr_month = d.getMonth()+1; //why need to add one? var curr_year = d.getFullYear(); return (curr_year + "-" + curr_month + "-" + curr_date ); } It works fine. What I don't understand is why do I need to add 1 to get the correct curr_month ? If I do not do this, the month will always be off

ASP.NET MVC DataAnnotations doesn't accept dd-MM-yyyy format

送分小仙女□ 提交于 2019-12-02 10:29:21
In my ASP.NET MVC 4 project I have a DateOfBirth field that uses the DataAnnotations Validation Date Attribute... [Required(ErrorMessage = "This field is required"), Date] public DateTime DateOfBirth { get; set; } I have set the format of my DatePicker control to dd-MM-yyyy (default was yyyy-MM-dd). But when I submit the form I am told that the date format is not valid. dd-MM-yyyy is a valid date format so why would it complain? Is there any way to fix this? Thanks try adding: [DisplayFormat(ApplyFormatInEditMode = true, DataFormatString = "{0:dd-MM-yyyy}")] 来源: https://stackoverflow.com

Save a formatted String to a LocalDate

半世苍凉 提交于 2019-12-02 07:18:32
I have a DateConverter class: public class DateConverter extends StringConverter<LocalDate> { String pattern = "EEE, dd. MM. uuuu"; DateTimeFormatter formatter = DateTimeFormatter.ofPattern(pattern,Locale.US); @Override public String toString(LocalDate object) { try { return formatter.format(object); } catch(Exception ex) { return ""; } } @Override public LocalDate fromString(String string) { try { return LocalDate.parse(string, formatter); } catch(Exception ex) { return null; } } public String getPattern(){ return pattern; } } And I have this piece of code: allProd.forEach((prod) -> {

ASP.NET Application is displaying american date formats

孤人 提交于 2019-12-02 04:27:20
问题 One of my development applications has today started displaying American formatted short dates where I am expecting British formatting. The dates are being rendered using date.ToShortDateString() I have already checked my Regional settings, keyboard settings, browser settings and web.config. These are all set to English (UK) or not changed. I've also rebooted a number of times. A mobile version of the same application, running from the same development server, and same website (different web

Format date in <f:selectItem(s) itemLabel> using DateTimeConverter

不想你离开。 提交于 2019-12-02 04:26:43
I have a <h:selectOneMenu> that has <f:selectItems> with CategoryHistory objects loaded in it. I only show the Date date field as itemLabel . That works but I want to format the date: I created a converter that extends javax.faces.convert.DateTimeConverter and change the fields in the constructor. But my dates only show in default format :( DateAndTimeConverter.java import javax.faces.bean.ManagedBean; import javax.faces.convert.Converter; import javax.faces.convert.DateTimeConverter; import javax.faces.convert.FacesConverter; @FacesConverter(value = "dateAndTimeconverter") @ManagedBean public

sqlite change date format of every cell in column

谁说我不能喝 提交于 2019-12-02 02:50:29
I have a table with a large number of rows. One column contains dates in the format '%m/%d/%Y' and I want to change all of them to format '%Y-%m-%d' the usual: update table set mydate = '6' doesn't work I guess because the date is always changing. How would I do that in this case? If the fields in the date string are properly padded with zeros, you can extract them as substrings : UPDATE MyTable SET MyDate = substr(MyDate, 7, 4) || '-' || substr(MyDate, 1, 2) || '-' || substr(MyDate, 4, 2) 来源: https://stackoverflow.com/questions/23125390/sqlite-change-date-format-of-every-cell-in-column

ASP.NET Application is displaying american date formats

女生的网名这么多〃 提交于 2019-12-02 01:29:31
One of my development applications has today started displaying American formatted short dates where I am expecting British formatting. The dates are being rendered using date.ToShortDateString() I have already checked my Regional settings, keyboard settings, browser settings and web.config. These are all set to English (UK) or not changed. I've also rebooted a number of times. A mobile version of the same application, running from the same development server, and same website (different web application) is working correctly. Environment: Windows 7 64 Bit Visual Studio 2010 Professional IIS 7

How do I configure the date formatter through Genson/Jersey?

拟墨画扇 提交于 2019-12-02 01:11:26
问题 I'm using Jersey for my RESTful services and Genson to perform my JSON/POJO conversion. There's no setup for Genson, I just drop it into the classpath and it just works, except that it throws an error on date parsing because the format is unexpected. Now, if I were to do this as a servlet, using Gson, I set the date format on a Gson instance that I maintain. That forces the parse of the POJO to use the correct format. I see that Genson has a similar interface, but I don't know how to get the

Encountering SQL Error: ORA-01843: not a valid month

大兔子大兔子 提交于 2019-12-01 23:33:36
I created a table using this query CREATE TABLE Store (id number(11) primary key not null, opening_time timestamp CHECK (EXTRACT(HOUR FROM opening_time) > 8 || NULL)); Now, when I try to insert some data using insert into Store values(1, '04/04/2012 13:35 PM'); , I encounter this error SQL Error: ORA-01843: not a valid month . What is it that I am doing wrong ? '04/04/2012 13:35 PM' is not a date - it is a string. Oracle will do an implicit TO_DATE( string_value, format_mask ) on non-date literals when inserting them into a DATE column using the value of the NLS_DATE_FORMAT session parameter

How do I configure the date formatter through Genson/Jersey?

六月ゝ 毕业季﹏ 提交于 2019-12-01 22:26:26
I'm using Jersey for my RESTful services and Genson to perform my JSON/POJO conversion. There's no setup for Genson, I just drop it into the classpath and it just works, except that it throws an error on date parsing because the format is unexpected. Now, if I were to do this as a servlet, using Gson, I set the date format on a Gson instance that I maintain. That forces the parse of the POJO to use the correct format. I see that Genson has a similar interface, but I don't know how to get the instance from the Jersey servlet service or maybe the Spring context so that I cat set the format. So,