format

Dynamic string formatting in c#

眉间皱痕 提交于 2020-01-05 07:17:11
问题 I created log method that accept string. When I want to use it I write something like: Log(string.Format("Message {0}", AdditionalInfo)); How should I implement Log method in order to be able to use string Format but do not have to write it explicitly in method arguments: Log("Message {0}", AdditionalInfo); I use .net 2.0 回答1: public void Log(string formatString, params object[] parameters) { Log(String.Format(formatString, parameters)); } 回答2: public void Log(string format, params object[]

Custom Formating a DateTimePicker using CultureInfo

倖福魔咒の 提交于 2020-01-05 06:45:12
问题 I am using the DateTimePicker control in a Vb.Net Windows project. I would like the date to reflect the Regional Settings on the user's computer, but also to show the month name, rather than the month number. For example, if my computer is set to English(US), I would like to see Nov 26 2009, and if my computer is set to English (NZ), I would like to see 26 Nov 2009 Is this possible? I know that I can set the CustomFormat property to say "dd MMM yyyy", but then that always shows 26 Nov 2009,

Convert Date to CYYMMDD SQL-Server

左心房为你撑大大i 提交于 2020-01-05 04:10:07
问题 I am interested in converting a date value to CYYMMDD using native SQL Server 2012 functions. I checked here: http://www.sql-server-helper.com/tips/date-formats.aspx and couldn't find anything. Anyone know? C stands for century I guess... 回答1: Have you looked at the new FORMAT function in SQL Server 2012? http://msdn.microsoft.com/en-us/library/hh213505.aspx You should be able to use something like this: SELECT FORMAT(YourDateColumn, 'yyyyMMdd') or whatever you really want to use - basically,

add $ and round 2 decimal places SQL

孤者浪人 提交于 2020-01-04 14:06:25
问题 I am looking to format an ouput which is created by a sub-query, this sub-query produces a calculated field which i would like to format as $XX.XX. Sub query: (select avg(retail) from cars where brand = 'FORD' or brand = 'TOYOTA') as AVG_BRAND_PRICE_01 I basically just want to add a $ sign and round the output to two decimal places. Any help or direction would be much appreciated. I am using isql plus oracle 11g 回答1: You could try this: '$' || Cast((select avg(retail) from cars where brand =

C#, Microsoft interop, Excel numberformat problem

◇◆丶佛笑我妖孽 提交于 2020-01-04 06:18:24
问题 I am using C# to try and format a range in Excel as numbers. When doing this, I get the green error arrow in the corner to ask me if I want to format the column as a number. I used the code below to format the data: Excel.Range Data = currentSheet.get_Range("K2:K10", Type.Missing); Data.NumberFormat = "0.00"; How do I convert the range to numbers so that excel is happy? 回答1: If your cells are already formatted as numbers, using the PasteSpecial function might work: Excel.Range Data =

PHP IntlDateFormatter format returns wrong date

Deadly 提交于 2020-01-04 05:14:31
问题 I'm getting incorrect results using IntlDateFormatter: $dateFormater = \IntlDateFormatter::create( 'en_EN', \IntlDateFormatter::LONG, \IntlDateFormatter::NONE ); $a = date('Y/m/d H:i:s',1332712800); //2012/03/26 00:00:00 $b = $dateFormater->format(1332712800); //March 25, 2012 But this only happens for dates between 2012/03/26 and 2012/10/28 and without hour (00:00:00). I can't find out what is the problem. Thanks for the help. 回答1: http://userguide.icu-project.org/datetime/timezone#TOC

Style a JTextPane to have console-like formatting?

人盡茶涼 提交于 2020-01-04 04:45:10
问题 Is there a way to make the text in a JTextPane look similar to that of console output? By that I mean, basically, how each character is the same width, so that things like ASCII art, or spacing indentation would work correctly. For example, currently, if I type "First" and then 5 spaces, and then on a new line "Second" and then 4 spaces, the two lines do not end in the same position, so if there was text following those spaces, the text would not be aligned. I don't know if it changes

Angular 2 Datepipe formatting based on browser location/settings

大城市里の小女人 提交于 2020-01-04 04:08:07
问题 Is there a way to make the datepipe dynamic so that if it's an American browser the datepipe returns the American format (yyyy/MM/dd) and when it's a European browser it returns the European format (dd/MM/yyyy)? Thanks 回答1: This can be hard, especially when using aot. It would normally require you to make different builds. I extended the datapipe and use the browsers locale. Datepipe: @Pipe({name: 'datepipe', pure: true}) export class MyDatePipe extends DatePipe implements PipeTransform {

How to format time intervals in Java?

醉酒当歌 提交于 2020-01-03 19:08:05
问题 I create J2SE application and this application needs to format two times in milliseconds into a string that represents the interval between this two times. long time1 = 1334331041677L; //Fri Apr 13 17:30:41 CEST 2012 long time2 = time1+1000*60*2; //Fri Apr 13 17:32:41 CEST 2012 and I would like to get something like "00:02:00". This would be simple, but I need to format interval which is long from few seconds up to several years - so the library should handle it. Ideally is if this library

How to format time intervals in Java?

做~自己de王妃 提交于 2020-01-03 19:06:09
问题 I create J2SE application and this application needs to format two times in milliseconds into a string that represents the interval between this two times. long time1 = 1334331041677L; //Fri Apr 13 17:30:41 CEST 2012 long time2 = time1+1000*60*2; //Fri Apr 13 17:32:41 CEST 2012 and I would like to get something like "00:02:00". This would be simple, but I need to format interval which is long from few seconds up to several years - so the library should handle it. Ideally is if this library