string-formatting

ASP.NET MVC Display Format does not format DateTime to just Date string.

I've got my display format setup as so <DisplayName("birthdate")> _ <DisplayFormat(ApplyFormatInEditMode:=True, DataFormatString:="{0:MM/dd/yyyy}")> _ Public Property BirthDate As DateTime Then in the View I have the following <%: Html.TextBoxFor(Function(model) model.BirthDate, Model.BirthDate)%> <%: Html.ValidationMessageFor(Functi...

WPF TextBox StringFormat not working with PropertyChanged

I have a problem. I need to have double formatted values in all TextBoxes. When you type something into this, after lost focus it will be formatted. <TextBox Text="{Binding ABC, StringFormat='{}{0:N}'}" /> Problem arises when you add this UpdateSourceTrigger with propertychanged. Then it will never be formatted. <TextBox Text="{Bi...

Possible to format a float in non-scientific format?

I'm trying to convert a float to a string without getting scientific (1.13E-8) style formatting. I'm looking for some combination of the "F" and "R" specifiers. I want the F so that it does not use the scientific style, but I also want the R so that it uses as little space as necessary to exactly represent the number. So given 0.000000...

Format Number based on Format String in JavaScript/jQuery

Let's say I have a format string "XXX - XXX - XXXX" (to format a phone number), or any other format string in which X stands for a number I want to preserve the formatting in the format string (spacing, dashes etc.), but exchange each X for a number and drop all formatting in the source string Examples: Input: "abc+d(123)4567890",...

Python: How do I format a number with a variable number of digits?

Say I wanted to display the number 123 with a variable number of padded zeroes on the front. For example, if I wanted to display it in 5 digits I would have digits = 5 giving me: '00123'. If I wanted to display it in 6 digits I would have digits = 6 giving: '000123'. How would I do this in Python? ...

string.Format fails at runtime with array of integers

Consider string.Format() whose parameters are a string and, among others in the overload list, an object[] or many objects. This statement succeeds: string foo = string.Format("{0} {1}", 5, 6); as does this: object[] myObjs = new object[] {8,9}; string baz = string.Format("{0} and {1}", myObjs; as does an array of strings: string...

Change default float print format

Hi, I've some lists and more complex structures containing floats. When printing them, I see the floats with a lot of decimal digits, but when printing, I don't need all of them. So I would like to define a custom format (e.g. 2 or 3 decimals) when floats are printed. I need to use floats and not Decimal. Also, I'm not allowed to trunca...

(iPhone app) error: too many arguments to function 'URLWithString:'

I'm trying to format a URL string however it's saying there are too many arguments. My code is below: -(IBAction)tweetRandom { //NSLog(@"CALLED"); test = 100; [[UIApplication sharedApplication] openURL:[NSURL URLWithString:@"http://twitter.com/%i", test]]; // problem line } Anyone know how to format the URL? Was hoping there was ...

Python - convert list of tuples to string

Which is the most pythonic way to convert a list of tuples to string? I have: [(1,2), (3,4)] and I want: "(1,2), (3,4)" My solution to this has been: l=[(1,2),(3,4)] s="" for t in l: s += "(%s,%s)," % t s = s[:-1] Is there a more pythonic way to do this? ...

SSRS Report Decimals

I have searched a bit upon it but can't get it to work properly. I want the report to display as many decimal characters as the field has, simple as that. Example: Value = 169.99 | Ouput = 169.99 Value = 169.9999 | Output = 169.9999 If I don't set the Format property to anything, it kinda aligns the fields, sometimes it returns 2...

Ruby formating '1' as '1st', '2' as '2nd' etc..

Pretty trivial question, I'm just looking to find out if anything is baked into ruby or rails to handle this. ...

Convert basic script to Objective C (money formatting)

Hello, I've got this basic like script that I need to convert to objective c, it turns big units of money into shortened versions (ie: 1.2m, etc), I've got most of the conversion done, but the biggest problem I'm having is right at the end. The original basic code is: ; Basic Code Function ShortCash$(BigNumber) out$="" ; First, ...

Format Telephone Number in GridView

I see another thread somewhat like my question at: http://stackoverflow.com/questions/1180403/asp-net-gridview-column-formatting-telephone-number but i do not know if it answers my question as he is using code-behind to make the colum. All I did was insert the GridView control in visual studio. BTW, the data is being populated in the G...

What is the proper way to format a TimeSpan as a countdown timer?

I have a timer that runs on the website. It will retrieve a timespan of how long a user has until their order expires. For the most part this works fine, the server will return the initial time remaining and the javascript will do the countdown. So it displays 2:30 2:29 2:28 Then for some reason, on some of the page loads (seems to hap...

Online Format String Tester

Is there a good online tool for testing .NET format strings? The tool would allow you to see how a format string would format a sample value. E.g. In Chris Sells old Format Designer utility you could enter a 1234.567 and a format string of "#,000.00" and the tool shows "1,234.57". ...

objective-c string, string-formatter

I have a program with which dreamlax worked a lot with me on, which uses Objective-C to convert temperatures between the Fahrenheit, Celsius, Kelvin and Rankine temperature scales, but converting console-input into Kelvin, and then from Kelvin to the end-user's desired temperature scale. Now, I have an idea I would like to implement for...

formatNumber : how to add 2 decimal digits at the back of numbers ?

Hi, I am using grails formatNumber and I would like to display my numbers in decimal format. I would like to display 10 as 10.00 or 0 as 0.00 with 2 decimal digits. how to do that ? ...

add space before a numbers in php

How can I add space before numbers in php, to get output like this:  9   10 100 i m using str_pad($k,3,'',STR_PAD_LEFT) but blank space is not working and i don't want leading zero but i want blank spaces ...

Include If Else statment in String.Format

Hi, I have the following statemnt. timespan = timespan.FromSeconds(236541) formattedTimeSpan = String.Format("{0} hr {1} mm {2} sec", Math.Truncate(timespan.TotalHours), timespan.Minutes, timespan.Seconds) I have to have it formatted as "hrs mn sec" if there are more than one hour. I want to check this within the String.Format ab...

C# Format String as Date

Hi I have a DetailsView with a TextBox bound to a DateTime column. The value of the column is presented in the format "dd/mm/yyyy hh:mm:ss". I need it to be displayed in the format "yyyy/mm/dd". I had though that the best way may be to format the string in the DataBound event. Problem is, I can't seem to find a way to format the string ...