Search Results

Search found 202 results on 9 pages for 'dateformat'.

Page 1/9 | 1 2 3 4 5 6 7 8 9  | Next Page >

  • Adroid's DateFormat replacement - missing the format() with FieldPosition

    - by user331244
    Hi, I need to split a date string into pieces and I'm doing it using the public final StringBuffer format (Object object, StringBuffer buffer, FieldPosition field) from the java.text.DateFormat class. However, the implementation of this function is really slow, hence Android has an own implementation in android.text.format.DateFormat. BUT, in my case, I want to extract the different pieces of the date string (year, minute and so on). Since I need to be locale independent, I can not use SimpleDateFormat and custom strings. I do it as follows: Calendar c = ... // find out what field to extract int field = getField(); // Create a date string Field calendarField = DateFormat.Field.ofCalendarField(field); FieldPosition fieldPosition = new FieldPosition(calendarField); StringBuffer label = new StringBuffer(); label = getDateFormat().format(c.getTime(), label, fieldPosition); // Find the piece that we are looking for int beginIndex = fieldPosition.getBeginIndex(); int endIndex = fieldPosition.getEndIndex(); String asString = label.substring(beginIndex, endIndex); For some reason, the format() overload with the FieldPosition argument is not included in the android platform. Any ideas of how to do this in another way? Is there any easy way to tokenize the pattern string? Any other ideas?

    Read the article

  • DateFormat conversion problem in java?

    - by androidbase Praveen
    my input String is : 2010-03-24T17:28:50.000Z output pattern is like: DateFormat formatter1 = new SimpleDateFormat("EEE. MMM. d. yyyy"); i convert this like this: formatter1.format(new Date("2010-03-24T17:28:50.000Z"));//illegalArgumentException here the string "2010-03-24T17:28:50.000Z" ouput should be like this: Thu. Mar. 24. 2010 idea but i get a illegalArgumentException. Dont know why? any idea?? stacktrace message is: 04-08 19:50:28.326: WARN/System.err(306): java.lang.IllegalArgumentException 04-08 19:50:28.345: WARN/System.err(306): at java.util.Date.parse(Date.java:447) 04-08 19:50:28.355: WARN/System.err(306): at java.util.Date.<init>(Date.java:157) 04-08 19:50:28.366: WARN/System.err(306): at com.example.brown.Bru_Tube$SelectDataTask.doInBackground(Bru_Tube.java:222) 04-08 19:50:28.366: WARN/System.err(306): at com.example.brown.Bru_Tube$SelectDataTask.doInBackground(Bru_Tube.java:1) 04-08 19:50:28.405: WARN/System.err(306): at android.os.AsyncTask$2.call(AsyncTask.java:185) 04-08 19:50:28.415: WARN/System.err(306): at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:305) 04-08 19:50:28.415: WARN/System.err(306): at java.util.concurrent.FutureTask.run(FutureTask.java:137) 04-08 19:50:28.446: WARN/System.err(306): at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1068) 04-08 19:50:28.456: WARN/System.err(306): at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:561) 04-08 19:50:28.466: WARN/System.err(306): at java.lang.Thread.run(Thread.java:1096)

    Read the article

  • Is this a Java DateFormat bug?

    - by anonymous
    The pattern is "dd-MM-yyyy" I think the string "01-01-2010mwwwwwwwwwwwwwww" does not satisfy the pattern, but the following code shows the contrary. Anyone can explain why? public static void main(String[] args) throws Exception { SimpleDateFormat df = new SimpleDateFormat("dd-MM-yyyy"); Date date = df.parse("01-01-2010mwwwwwwwwwwwwwww"); System.out.println(date); } Thanks

    Read the article

  • Java Time Zone When Parsing DateFormat

    - by shipmaster
    I had code that parses date as follows: String ALT_DATE_TIME_FORMAT = "yyyy-MM-dd'T'HH:mm:ss.SSSZ"; SimpleDateFormat sdf = new SimpleDateFormat( ALT_DATE_TIME_FORMAT); Date date = sdf.parse(requiredTimeStamp); And it was working fine, suddenly, this stopped working. It turns out an admin made some config changes on the server and the date is currently being returned as "2010-12-27T10:50:44.000-08:00" which is not parse-able by the above pattern. I have two questions: The first would be what pattern would parse the date being returned by the JVM in the format above (specifically, just '-08:00' as the time zone)? And second, where exactly would one change such settings on a linux RHEL 5 server so that we are aware of such changes in the future?

    Read the article

  • SimpleDateFormat give inconsistent results

    - by Julien Gagnet
    I am trying to parse a date and I am getting different results when I run the code locally/BST compare to a server in Paris/CEST. I've reproduced the issue in a the following sample. This is trying to parse the start date for the Australian Grand Prix. TimeZone tz = TimeZone.getTimeZone("AET"); DateFormat dateFormat = new SimpleDateFormat("dd/MM/yyyy HH mm"); dateFormat.setTimeZone(tz); long time = dateFormat.parse("28/03/2010 17 00").getTime(); System.out.println("Time "+time); It seems like I am setting the timezone correctly on the date format and the current timezone shouldn't be affecting the code. But locally it prints 1269756000000 and in Paris 1269759600000. Any idea?

    Read the article

  • Javascript DateFormat for different timezones

    - by Elie
    I'm a Java developer and I'm used to the SimpleDateFormat class that allows me to format any date to any format by settings a timezone. Date date = new Date(); SimpleDateFormat sdf = new SimpleDateFormat("dd-MM-yyyy hh:mm:ss"); sdf.setTimeZone(TimeZone.getTimeZone("America/Los_Angeles")); System.out.println(sdf.format(date)); // Prints date in Los Angeles sdf.setTimeZone(TimeZone.getTimeZone("America/Chicago")); System.out.println(sdf.format(date)); // Prints same date in Chicago SimpleDateFormat is a pretty neat solution in Java but unfortunately I can't find any similar alternative in Javascript. I'm extending the Date prototype in Javascript to do exactly the same. I have dates in Unix format but I want to format them in different timezones. Date.prototype.format = function(format, timezone) { // Now what? return formattedDate; } I'm looking for a neat way to do this rather than a hack. Thanks

    Read the article

  • symfony sfValidatorSchemaCompare and dateformat output problem

    - by Gerbrand
    public function configure() { $this->widgetSchema['start_date'] = new sfWidgetFormInput(); $this->widgetSchema['end_date'] = new sfWidgetFormInput(); $this->validatorSchema->setPostValidator( new sfValidatorOr ( array( new sfValidatorAnd( array (new sfValidatorSchemaCompare('start_date', sfValidatorSchemaCompare::NOT_EQUAL, null), new sfValidatorSchemaCompare('end_date', sfValidatorSchemaCompare::EQUAL, null) )), new sfValidatorSchemaCompare('start_date', sfValidatorSchemaCompare::LESS_THAN_EQUAL, 'end_date', array('throw_global_error' => false), array('invalid' => 'The start date ("%left_field%") must be before the end date ("%right_field%")'))))); } I've got following input dates which I want to check if the end date isn't before the start date: Input: Start = 31/03/10 End= 07/03/10 Output: The start date (2010-03-31) must be before the end date (2010-03-07) Can you in some way change the date output? I need the error message to set the date format the same as the input. Also my input fields are set with the wrong date format when the error appears. Tried several things, but no luck at this moment. Didn't find a solution or information on symfony it self. I'm using symfony version 1.2.11

    Read the article

  • Weird behaviour of Calendar and DateFormat

    - by Nejc
    I encountered really strange behaviour when constructing a Calendar object and then formating it in a particular style. Let the code do the talking: public class Test { public static void main(String[] args) { SimpleDateFormat frmt = new SimpleDateFormat(); frmt.applyPattern("yyyy-MM-dd"); GregorianCalendar date = new GregorianCalendar(2012,1,1); System.out.println(frmt.format(date.getTime())); } } The output is: 2012-02-01 The expected output is of course: 2012-01-01 What am I doing wrong?

    Read the article

  • asp.net gridview bind dateformat not working with update

    - by Brabbeldas
    I have a GridView with a TemplateField column which shows a DateTime from a DataSource. <Columns> <asp:CommandField ShowEditButton="True" /> <asp:TemplateField HeaderText="Start Date"> <EditItemTemplate> <asp:TextBox ID="txtDateStart" runat="server" Text='<%# Bind("dtDateStart", "{0:dd/MM/yyyy}") %>'</asp:TextBox> </EditItemTemplate> <ItemTemplate> <asp:Label ID="Label1" runat="server" Text='<%# Bind("dtDateStart", "{0:dd/MM/yyyy}") %>'></asp:Label> </ItemTemplate> </asp:TemplateField> </Columns> Displaying the date in the correct format works as it should. Note that the format starts with DAY followed by MONTH. When I switch to edit mode, change the date in the TextBox to '31-01-2013' and press the GridView's update-link i get an error: Cannot convert value of parameter 'dtDateStart' from 'System.String' to 'System.DateTime' The error is generated by the GridView not my own code. It happens before the UpdateMethod of my DataSource is called. When i type '01-31-2012' the data is processed correctly and the value is updated into the database. Somehow when the date is displayed it uses format dd-MM-yyyy (just as I need it to) But when it reads the new value form the TextBox it uses MM-dd-yyyy Can somebody please help me?

    Read the article

  • DateFormat on DisplayFor not working

    - by user335160
    I've set the Data Annotation for date, it works when I use the EditorFor but when I use the DisplayFor it is not working. The date is come from a collection of data. I get this format 8/13/2011 12:00:00 AM instead of 8/13/2011. What is wrong with the code. Data Annotation for Date [DisplayName("Date")] [DisplayFormat(ApplyFormatInEditMode = true, DataFormatString = "{0:MM/dd/yyyy}")] [Required(ErrorMessage = "Date required.")] public object EM_Date { get; set; } View Code @foreach (EventViewModel item in Model) { <tr> <td class="AdBoxBodyRow1" style="text-align: center"> @Html.DisplayFor(modelItem => item.EM_Date) </td> </tr> }

    Read the article

  • convert String "11-10-10 12:00:00" into Date Object

    - by Mahendra Athneria
    Hi, I want to convert String "11-10-10 12:00:00" into Date object but i am not able to do so. can you please help me out? below is the code snippet. i have the Date obj which has the value = Mon Oct 11 00:00:00 IST 2010 DateFormat newDateFormat = new SimpleDateFormat("dd-MM-yy hh:mm:ss"); String strDate = newDateFormat.format(tempDate); //**i got strDate as strDate is : 11-10-10 12:00:00** DateFormat newDateFormat1 = new SimpleDateFormat("dd-MM-yy hh:mm:ss"); try { tempDate = newDateFormat1.parse(strDate); // **getting tempDate as - Mon Oct 11 00:00:00 IST 2010** } catch (ParseException e) { // TODO Auto-generated catch block e.printStackTrace(); } Can someone help me to solve this issue? Regards, Mahendra Athneria Mumbai, India

    Read the article

  • set calendar extender format

    - by Atzoya
    Does anyone know if there is a way of specifying the Format of a calendar extender with a dynamic value from the aspx? I tried this but it doesnt seem to set the format at all. Does anyone see anything wrong with it: <asp:TextBox ID="tbStartDate" runat="server" /> <act:CalendarExtender ID="clndrStartDate" PopupPosition="Right" runat="server" Format='<%# DefaultDateFormat %>' TargetControlID="tbStartDate"></act:CalendarExtender> and i have the DefaultDateFormat getter in a base page of the code beheind like this: public static string DefaultDateFormat { get { return "dd/MM/yyyy"; } } Any help would be appretiated. Thank you

    Read the article

  • Compare date from database using parameters

    - by Simon
    string queryString = "SELECT SUM(skupaj_kalorij)as Skupaj_Kalorij " + "FROM (obroki_save LEFT JOIN users ON obroki_save.ID_uporabnika=users.ID)" + "WHERE (users.ID= " + a.ToString() + ") AND (obroki_save.datum= @datum)"; using (OleDbCommand cmd = new OleDbCommand(queryString,database)) { DateTime datum = DateTime.Today; cmd.Parameters.AddWithValue("@datum", datum); } loadDataGrid2(queryString); I tried now with parameters. But i don't really know how to do it correctly. I tried like this, but the parameter datum doesn't get any value(according to c#).

    Read the article

  • What is the correct date format for a Date column in YUI DataTable ?

    - by giulio
    I have produced a data table. All the columns are sortable. It has a date in one column which I formatted dd/mm/yyyy hh:mm:ss . This is different from the default format as defined in the doco, but I should be able to define my own format for non-american formats. (See below) The DataTable class provides a set of built-in static functions to format certain well-known types of data. In your Column definition, if you set a Column's formatter to YAHOO.widget.DataTable.formatDate, that function will render data of type Date with the default syntax of "MM/DD/YYYY". If you would like to bypass a built-in formatter in favor of your own, you can point a Column's formatter to a custom function that you define. The table is generated from HTML Markup, so the data is held within "" tags. This gives me some more clues about compatible string dates for javascript: In general, the RecordSet expects to hold data in native JavaScript types. For instance, a date is expected to be a JavaScript Date instance, not a string like "4/26/2005" in order to sort properly. Converting data types as data comes into your RecordSet is enabled through the parser property in the fields array of your DataSource's responseSchema I suspect that the I'm missing something in the date format. So what is an acceptable string date for javascript, that Yui dataTable will recognise, given that I want format it as "dd/mm/yyyy hh:mm:ss" ?

    Read the article

  • Date format in SQLite - iphone - How ?

    - by sagar
    I know that - SQLite doesn't support Day name & month name. I have gone through this question. I have created two custom functions for it. My custom function for Converting Day name from day number ( %w day of week 0-6 with sunday==0 ) +(NSString*)dayNameStringFromDayNo:(NSString*)dayNo{ return ([dayNo isEqualToString:@"0"])?@"Sunday": ( ([dayNo isEqualToString:@"1"])?@"Monday": ( ([dayNo isEqualToString:@"2"])?@"Tuesday": ( ([dayNo isEqualToString:@"3"])?@"Wednesday": ( ([dayNo isEqualToString:@"4"])?@"Thursday": ( ([dayNo isEqualToString:@"5"])?@"Friday": @"Saturday" ) ) ) ) ); } My custom method for getting month name from month no string ( %m month: 01-12 ) +(NSString*)monthNameFromNumber:(NSString*)no{ return ([no isEqualToString:@"01"])?@"January": ( ([no isEqualToString:@"02"])?@"February": ( ([no isEqualToString:@"03"])?@"March": ( ([no isEqualToString:@"04"])?@"April": ( ([no isEqualToString:@"05"])?@"May": ( ([no isEqualToString:@"06"])?@"June": ( ([no isEqualToString:@"07"])?@"July": ( ([no isEqualToString:@"08"])?@"August": ( ([no isEqualToString:@"09"])?@"September": ( ([no isEqualToString:@"10"])?@"October": ( ([no isEqualToString:@"11"])?@"November":@"Decemeber" ) ) ) ) ) ) ) ) ) ); } But what about date following format. Sat 6th February How to get this kind of output ? Do I have to again create a custom function for it ? Thanks in advance for sharing your knowledge. Sagar.

    Read the article

  • Human readable and parsable date format in Java.

    - by Savvas Dalkitsis
    I want to save a Date object to a readable string (for example 22/10/2009 21:13:14) that is also parsable back to a Date object. I have tried many things and the best I could find was to use DateFormater for parsing and formating but it has a setback. When you format a date you lose seconds information. I tried to find if there is an option to format it and display the seconds (even better would be to the millisecond level since that's the resolution the Date object allows you to have) but I came up short. Any ideas?

    Read the article

  • flex3 Format date without timezone

    - by Maurits de Boer
    I'm receiving a date from a server in milliseconds since 1-1-1970. I then use the DateFormatter to print the date to the screen. However, Flex adds timedifference and thus it displays a different time than what I got from the server. I've fixed this by changing the date before printing to screen. But I think that's a bad solution because the date object doesn't hold the correct date. Does anyone know how to use the dateFormatter to print the date, ignoring the timezone? this is how I did it: function getDateString(value:Date):String { var millisecondsPerMinute:int = 1000*60; var newDate:Date = new Date(value.time - (millisecondsPerMinute*value.timezoneOffset)); var dateFormatter:DateFormatter = new DateFormatter(); dateFormatter.formatString = "EEEE DD-MM-YYYY LL:MM AA"; return dateFormatter.format(newDate); }

    Read the article

  • vb.net date format from textbox > MS SQL query

    - by Jonesy
    Hi folks, I have a date column in a DB tabel that I want to query using a date taken from textbox.text. the user selects a date from the calendar in the format dd/MM/yyyy. I want to use that date to put into a query. How do i format the date to be able to query the database? Dim datefrom As String =txtDateFrom.Text Dim dateto As String =txtDateTo.Text The query will look like this: WHERE (tblClient.ClientID = " & ClientID & ") AND (tblBackupArchive.BackupDate BETWEEN '" + datefrom + "' AND '" + dateto + "')" I'm using MS SQL Server btw. Any help most appreciated. Jonesy

    Read the article

  • format result of dat calc in linq

    - by d daly
    Hi I have a calculation in a linq query, although it brings back the correct nuber of days, Im not sure how to better format it select new { time = (System.DateTime.Today - cs.date_case_opened), }; just now it shows eg 4:00:00:00 if the difference is 4 days, any ideas how i can present this better? thanks

    Read the article

  • Date in textboxes changing format

    - by AWinters
    I have an application (asp.net 3.5) that support 4 different languages. Along with other cultural changes, the date formats must match the current culture on out reporting pages. We set the date formats of each of the textboxes like: string date = DateTime.Today.ToString("d"); //returns the date portion only textbox1.Text = date; textbox2.Text = date; etc... When the user selects Spanish or British English the format should be dd/mm/yyyy. However, then I navigate to the page it displays in mm/dd/yyyy. After a postback it then displays dd/mm/yyyy. After another postback it switches to the mm/dd/yyyy format and on and on. I have debugged through this and I see that the culture is correct for the application and the date formats are returned to me correctly, yet when it displays, it displays incorrectly. Has anyone ever seen this or know what is happening?

    Read the article

  • Compare date from database and in program

    - by Simon
    database = new OleDbConnection(connectionString); database.Open(); date = DateTime.Now.ToShortDateString(); string queryString = "SELECT SUM(skupaj_kalorij)as Skupaj_Kalorij " + "FROM (obroki_save LEFT JOIN users ON obroki_save.ID_uporabnika=users.ID)" + "WHERE users.ID= " + a.ToString()+" AND obroki_save.datum= " +DateTime.Today.ToShortDateString(); loadDataGrid2(queryString); I get an error,when i wan't to select the result. Why?

    Read the article

  • Is my Joda Time format pattern incorrect to produce a `T` and `Z` inside the parsed DateTime output?

    - by Tree
    Using Joda Time's pattern syntax below, this input string: Sunday, January 09, 2011 6:15:00 PM becomes this datetime: 2011-01-09T06:15:00.000Z Code: String start = "Sunday, January 09, 2011 6:15:00 PM"; DateTimeFormatter parser1 = DateTimeFormat.forPattern("EEEE, MMMM dd, yyyy H:mm:ss aa"); DateTime startTime = parser1.parseDateTime(start); Is this format pattern incorrect? If not, what are the T and Z doing inside the DateTime output? 2011-01-09T06:15:00.000Z

    Read the article

1 2 3 4 5 6 7 8 9  | Next Page >