date-format

Jax ws- xs:date format validation

大城市里の小女人 提交于 2020-01-04 19:04:10
问题 I have this in my XSD (please check code below): <xs:element name="Report_Date" type="xs:date" minOccurs="0"/> it is true that this field accepts only the date format yyyy-mm-dd and if any other format is given, JAXB unmarshalls it as null. But i want to validate the report_date field for incorrect format given in the request. Since this is an optional field, the application behaves same for even when the date not given and when the date is given in incorrect format. To make it simple, i want

Best method for parsing date formats during import datas

僤鯓⒐⒋嵵緔 提交于 2020-01-04 06:33:12
问题 I created method for parsing a view different date formats during data import (400 K records). My method catches ParseException and trying to parse date with next format when it's different. Question: Is better way(and faster) to set correct date format during data import? private static final String DMY_DASH_FORMAT = "dd-MM-yyyy"; private static final String DMY_DOT_FORMAT = "dd.MM.yyyy"; private static final String YMD_DASH_FORMAT = "yyyy-MM-dd"; private static final String YMD_DOT_FORMAT =

problem on java calendar function

a 夏天 提交于 2020-01-04 05:13:16
问题 I declared Calendar and SimpleDateFormat like this: calendar = Calendar.getInstance(TimeZone.getTimeZone("Malaysia")); final SimpleDateFormat sdf = new SimpleDateFormat("yyyy.MMMMM.dd hh:mm aaa"); or: calendar = Calendar.getInstance(TimeZone.getTimeZone("GMT+08:00")); Then I call this: sdf.format(calendar.getTime()); but result is not in correct time zone (+8 hours). What could be the problem? 回答1: Unless you are going to perform Date/Time related calculations, there is no point in

How do you format a date range in Java?

空扰寡人 提交于 2020-01-03 20:56:18
问题 I have two dates - a start and an end. I'd like to format them so that if the months match, they collapse to something like "20-23 AUG" and still format correctly if they break over the end of the month, like "20 SEP - 1 OCT". Are there any libraries out there for accomplishing this, or would I have to hand code rules for displaying ranges of dates using individual DateFormats? 回答1: Here's a solution using JodaTime, the best library for dealing with dates in Java (last time I checked). The

Proper DateTime Format for a Web Service

给你一囗甜甜゛ 提交于 2020-01-03 08:47:10
问题 I have a webservice with a method which is called via a xmlhttprequest object in my javascript. The method accepts a datetime parameter which is subsequently converted to a string and run against the database to perform a calculation. I get the value from m_txtDateAdd and send off the xmlHttprequest <asp:textbox id=m_txtDateAdd tabIndex=4 runat="server" Width="96px" Text="<%# Today %>"> </asp:textbox> which has a validator attacted to it <asp:CustomValidator id="m_DateAddValidator" runat=

Extjs date column format

为君一笑 提交于 2020-01-03 03:26:47
问题 i have date column with datefield editor. The problem is that while im editing column it displays the normal value for example 2013-02-05 , but when close editing it displays something like Sat Jul 12 2014 00:00:00 GMT+0300 (FLE Standard Time) My code: { xtype : 'datecolumn', dataIndex : 'depreciationStartPeriod', header : 'Depreciation start period', sortable : true, id : 'depreciationStartPeriod', width : 134, editor : { xtype : 'datefield', format: 'Y-m-d H:i:s' } } store field: { name :

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?

一曲冷凌霜 提交于 2020-01-02 08:22:11
问题 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? 回答1: 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: //

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

半腔热情 提交于 2020-01-02 07:35:56
问题 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

Format a datetime string to time only

两盒软妹~` 提交于 2020-01-02 05:43:10
问题 I'm retrieving a datetime from a SQLite DB which comes out in the format... 2011-01-24 02:45:00 In C# I can simply use DateTime.Parse("2011-01-24 02:45:00").ToString("HH:mm") in order to get the string 02:45 Is their a way I can I do this in Android/Java? My code in my Android app looks like this... // dateStr below is logging as correctly being yyyy-MM-dd HH:mm:ss format String dateStr = cursor.getString(cursor.getColumnIndex("start_time")); SimpleDateFormat sdf = new SimpleDateFormat("HH:mm

Date validation for Java 8 Time API in Spring

ぃ、小莉子 提交于 2020-01-01 19:27:25
问题 We all know the classic example of a date validation in the controller inside the initBinder method: @InitBinder public void initBinder(WebDataBinder binder) { SimpleDateFormat dateFormat = new SimpleDateFormat("dd.MM.yyyy HH:mm"); binder.registerCustomEditor(Date.class, new CustomDateEditor(dateFormat, true)); } But what is the alternative to support the new Java 8 Time API , where we need to replace DateFormat to DateTimeFormatter ? What tools Spring Framework provides for this? Thanks. 回答1