formatting

What's the most efficient way to format the following string?

I have a very simple question, and I shouldn't be hung up on this, but I am. Haha! I have a string that I receive in the following format(s): 123 123456-D53 123455-4D 234234-4 123415 The desired output, post formatting, is: 123-455-444 123-455-55 123-455-5 or 123-455 The format is ultimately dependent upon the total number o...

How do I change a date's format in PHP?

I get data from a database in YYYY-mm-dd format, but I want to show just dd.mm (example - I get 2010-05-28; I want to show 28.05) Could you help me? Thanks ...

How to turn a list of tuples into a string?

I have a list of tuples that I'm trying to incorporate into a SQL query but I can't figure out how to join them together without adding slashes. My like this: list = [('val', 'val'), ('val', 'val'), ('val', 'val')] If I turn each tuple into a string and try to join them with a a comma I'll get something like ' (\'val\, \'val\'), ... ...

how to print number with commas as thousands separators in Javascript

I am trying to print an integer in Javascript with commas as thousands separators. For example, I want to show the number 1234567 as "1,234,567". How would I go about doing this? Here is how I am doing it: function numberWithCommas(x) { x = x.toString(); var pattern = /(-?\d+)(\d{3})/; while (pattern.test(x)) x = x.r...

CSS Table Formatting to a HTML Table

I am attempting to provide CSS formating to two HTML tables, but I cannot. I am setting up a webpage in HTML & CSS (with the CSS in an external sheet) and the layout of the website depends on the tables. There are 2 tables, one for the head and another for the body. They are set up whereas content is situated in one middle column of 60...

c++ manipulator question

i have a class: template<class T> class matrix { private: int COLS,ROWS; public: inline matrix(int r,int c){ this->COLS=r; this->ROWS=c; } template<class T2> friend ostream& info(ostream& os); }; i tried in so many ways to implement the info function.but none is succeed. i want to use it in main f...

Replicating Java's DecimalFormat in C#

I am trying to replicate a subset of Java's DecimalFormat class. Below is what I've come up with. Does this look right to everyone? public class DecimalFormat : NumberFormat { int _maximumFractionDigits; int _minimumFractionDigits; string _format; void RebuildFormat () { _format = "{0:0."; ...

Best ways to format LINQ queries.

Before you ignore / vote-to-close this question, I consider this a valid question to ask because code clarity is an important topic of discussion, it's essential to writing maintainable code and I would greatly appreciate answers from those who have come across this before. I've recently run into this problem, LINQ queries can get prett...

Get "2:35pm" instead of "02:35PM" from Python date/time?

I'm still a bit slow with Python, so I haven't got this figured out beyond what's obviously in the docs, etc. I've worked with Django a bit, where they've added some datetime formatting options via template tags, but in regular python code how can I get the 12-hour hour without a leading zero? Is there a straightforward way to do thi...

Show nothing when 0 JasperReports format

I want to show nothing when a numeric value is zero (strict no zeros at left) What JasperReports format should I use so spreadsheet output like XLS gets empty cell when the value is zero 0;-0;;@ format? ...

Is There A Way To Apply CODE Formatting To A VB.Net TextBox?

I'm playing with a simple string replacement editor for editing VB.Net functions outside of VB. Is there a way to apply VB.Net code formatting to a string? For example. The txtboxCodeEntry looks like this: If strVar="dummy" then 1 else 0 Endif I would like it to "autoformat" to: If strVar = "dummy" Then 1 Else 0 End If The f...

Formatting Markup Files in ASP.NET

What have you found to be the best way to format your ASP.NET markup files (aspx, ascx) for readability? Any tips and/or tricks? I'm looking for comments on indentation, line-wrapping, naming schemes, <%-- --%> commenting, or whatever you can think of. ...

how to turn off percentage sign in .net/wpf?

I would like my WPF application to display all percentages without % sign. For example 20% would be displayed as "20" but i still want to use the standard formatting for percentages (so i get the benefit of string formatter to multiply it by 100 for me) in other words, how do i get string.Format("0.00%", 0.2) to output "20" but not "20%...

Remove trailing zeros from decimal in SQL Server

I have a column DECIMAL(9,6) i.e. it supports values like 999,123456. But when I insert data like 123,4567 it becomes 123,456700 How to remove those zeros? ...

how to format jsf 2.0 <f:selectItems/> with date value from List

Hi, Im using jsf 2.0 to develop app where user has to select (using radio button) a date from the list of possible choices. List of dates is a managed bean property of type List< java.util.Date>. Im using facelets <h:selectOneRadio value="#{banner_backing.selectedInterval}" border="1" layout="pageDirection"> <f:selectItems val...

create a YYYY-MM-DD Daterange in JScript/Javascript.

Hello. I need no generate a full daterange in JScript from a given Startdate to now. Startdate: 2010-03-25 2010-03-26 2010-03-27 ... 2010-05-30 I am very confused with Javascript Date. best would be a function to give a daterange as params and getting an Array of the formatted date back, something like that: range[0] = 2010-03-25 ra...

how to convert current date into string in java?

how to convert current date into string in java? ...

Format double value in scientific notation

I have a double number like 223.45654543434 and I need to show it like "0.223x10E-3". How can I do this in Java? ...

Formatting this JavaScript Line

Hi, I am trying to format this line of code in my popup window, but i am facing unterminated string literal error. Can somebody please tell me how best I could format this. window.setTimeout("winId.document.write('<script src="../js/tiny_mce/tiny_mce.js" type="text/javascript"></script>\n')", 10); Also point out if this particular l...

converting time from hh:mm:ss to hh:mm in java

hi every one, I want to force the print screen of time like => hh:mm it comes from database (my sql) like hh:mm:ss. I tryed the following but i didn't got want i want. try { s= HibernateUtil.currentSession(); tx=s.beginTransaction(); Query query = s.createQuery("select from Dailytimesheet dailytimesheet where d...