date-format

How can process a date that is in d/m/yyyy?

牧云@^-^@ 提交于 2019-12-06 10:04:57
I have to process dates . If the format i specify is mm/dd/yyyy and the date is like 7/5/2013, it is throwing a format exception. Does the date has to be like 07/05/2013? If yes how can i change the date from 7/5/2013 to 07/05/2013 programatically ? and the date format is not specific. I can have dates in mm-dd-yyyy or yyyy-mm-dd and the dates can come like 7-5-2013. Use the ParseExact method, and specify the format as M/d/yyyy (or d/M/yyyy , depending on what exactly you need): var date = DateTime.ParseExact(input, "M/d/yyyy"); There is also an overload which can handle multiple date formats:

How to show Persian numbers on ASP.NET MVC page?

为君一笑 提交于 2019-12-06 08:03:11
问题 I'm building a site which needs to support both English and Persian language. The site is built with ASP.NET MVC 3 and .NET 4 (C#). All my controllers inherit from a BaseController, which sets culture to "fa-IR" (during test): Thread.CurrentThread.CurrentCulture = new CultureInfo("fa-IR"); Thread.CurrentThread.CurrentUICulture = new CultureInfo("fa-IR"); In my views, I'm using static helper classes to convert into right timezone and to format date. Like: DateFormatter.ToLocalDateAndTime(model

How to change datagridview column date format when gridview has autogeneratecolumns=true

天涯浪子 提交于 2019-12-06 04:30:39
问题 I am auto generating columns in gridview depending on search parameters, few columns will be added or removed. Please suggest me a way to set the date format to dd-mmm-yyyy for entire column in gridview. For now, I'm doing it using rowdatabound . It checks every row, So it takes time to show the results. This is what I do in rowdatabound if (e.Row.RowType == DataControlRowType.DataRow) { System.Data.DataRowView dtview; DateTime dt; int intCounter; dtview = (DataRowView)e.Row.DataItem; for

Java Date sorting method?

≯℡__Kan透↙ 提交于 2019-12-06 02:45:17
I have an String array of dates in the format ex:'2010-05-04 11:26:46 +0530'. How can I check whether a particular date in the array is > today? thanks DateFormat df = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss Z"); df.parse(datearray[i]).after(new Date()) 来源: https://stackoverflow.com/questions/2786379/java-date-sorting-method

SQL DML: Incorrect date value (MySQL)

我是研究僧i 提交于 2019-12-06 02:35:08
问题 I created a table in my database: CREATE TABLE official_receipt( student_no INT UNSIGNED, academic_year CHAR(8), trimester ENUM('1', '2', '3'), or_no MEDIUMINT UNSIGNED, issue_date DATE NOT NULL, received_from VARCHAR(255) NOT NULL, amount_of DECIMAL(8,2) NOT NULL, issued_by VARCHAR(255), doc_type ENUM('FULL', 'DOWN', 'INST') NOT NULL, form_of_payment ENUM('CASH', 'INST') NOT NULL, PRIMARY KEY (student_no, academic_year, trimester, or_no) ); I inserted some values: INSERT INTO official

How to convert a DD-MM-YYYY date format string into a YYYY-MM-DD date format string or into a NSDate object in Objective-C?

寵の児 提交于 2019-12-06 02:04:28
I have read date from XML which give me back string where the date is like DD-MM-YYYY . But when I want to add it to my core data database, SQLite sorts me that wrong so I have to convert it to date format or to string like: YYYY-MM-DD . But SQLite does not support either Date() or To_Date() functions. Can you help me? Nick Cartwright You can use NSDateFormatter to format a date in Objective C. Here's a quick example which might not do exactly what you want, but should hopefully give some pointers: // Convert my dd-mm-yyyyy string into a date object NSString *stringDate = @"01-02-2011";

where does asp and iis 6.0 get its date format

别说谁变了你拦得住时间么 提交于 2019-12-06 00:10:19
I've found a dilly of a pickle with a new web server. We have a new web server that is displaying dates differently than our old web servers. We are running asp classic web pages on IIS 6.0 with windows server 2003. We have logged in as an administrator and set the regional settings as appropriate and then applied the settings to current user and default user profile. We then went into registry and update the appropriate formats under HKEY_USERS/.default/control panel/international. Update the asp.net configuration for our websites to the correct code-page and locale. Does anyone have other

Rails not picking up custom date & time formats in en.yml

ぐ巨炮叔叔 提交于 2019-12-05 22:31:11
I'm not that familiar with I18N in Rails so bear with me. Trying to set a custom date & time format: #config/locales/en.yml en: date: formats: long_dateweek: "%A, %B %d, %Y" time: formats: very_short: "%H:%M" But when I try to use them I just get the default formats: 1.9.3p194 :001 > Time.now.to_date.to_s(:long_dateweek) => "2012-08-22" 1.9.3p194 :002 > Time.now.to_time.to_s(:very_short) => "2012-08-22 16:12:47 -0700" Tried restarting console (and even the server) to no avail... What'd I miss? You need to use the I18n.l method as follows: 1.9.3p194 :001 > I18n.l Time.now.to_date, :format =>

Oracle SQL convert date format from DD-Mon-YY to YYYYMM

雨燕双飞 提交于 2019-12-05 17:42:13
I have a to compare dates in 2 tables but the problem is that one table has the date in DD-Mon-YY format and the other in YYYYMM format. I need to make both of them YYYYMM for the comparison. I need to create something like this: SELECT * FROM offers WHERE offer_date = (SELECT to_date(create_date, 'YYYYMM') FROM customers where id = '12345678') AND offer_rate > 0 where create_date is something like 12-Mar-2006 and offer_date is something like 200605 Any ideas where I need to adapt this query?? As offer_date is an number, and is of lower accuracy than your real dates, this may work... - Convert

Jodatime date format

久未见 提交于 2019-12-05 17:10:54
Is it possible to format JodaTime Date. Here is the code: private static LocalDate priorDay(LocalDate date1) { do { date1 = date1.plusDays(-1); } while (date1.getDayOfWeek() == DateTimeConstants.SUNDAY || date1.getDayOfWeek() == DateTimeConstants.SATURDAY); //System.out.print(date1); return date1; } Here date1 returns as: 2013-07-02 but i would like as 02-JUL-13 Thanks in advance Is it possible to format JodaTime Date Yes. You want DateTimeFormatter . DateTimeFormatter formatter = DateTimeFormat.forPattern("dd-MMM-yy") .withLocale(Locale.US); // Make sure we use English month names String text