format

Inserting commas into integers

心不动则不痛 提交于 2021-02-07 14:36:40
问题 In Android is there an easy way to insert commas into a numberical value? ie if I have an EditText with 12345 in it, how can I display this as 12,345? I think I can do it using substring and chopping it up into x number of 3 number chunks then concatenating the answer with ',' between each 3 number chunk. This would be pretty easy if length of number was constant, but as the number could be from one digit to, say 20, it makes it more complex. Just curious if there is a simple and clean way to

Inserting commas into integers

六眼飞鱼酱① 提交于 2021-02-07 14:31:16
问题 In Android is there an easy way to insert commas into a numberical value? ie if I have an EditText with 12345 in it, how can I display this as 12,345? I think I can do it using substring and chopping it up into x number of 3 number chunks then concatenating the answer with ',' between each 3 number chunk. This would be pretty easy if length of number was constant, but as the number could be from one digit to, say 20, it makes it more complex. Just curious if there is a simple and clean way to

How do I convert a DateTime object to YYMMDD format?

放肆的年华 提交于 2021-02-07 11:40:49
问题 Um, probably a really simple question, but I just noticed that I have no idea on how to convert DateTime.Now to the format YYMMDD, so for example today (5. November 2009) would be "091105". I know there are overloads to DateTime.Now.ToString() where you can pass in a format string, but I have not found the right format e.g. for short year format (09 instead of 2009). 回答1: DateTime.Now.ToString("yyMMdd") You may also find the following two posts on MSDN useful as they contain a lot of info

Is there a name for the date format “YYYY-MM-DD HH:MM:SS”?

爷,独闯天下 提交于 2021-02-07 05:28:05
问题 For talking over the phone or to my co-workers, is there a short-hand name for this date format already established? Names of other standard date formats would also be useful. 回答1: That is the ISO standard date and time. 回答2: ISO 8601 来源: https://stackoverflow.com/questions/8579293/is-there-a-name-for-the-date-format-yyyy-mm-dd-hhmmss

NPOI Date Format Cell

社会主义新天地 提交于 2021-02-07 03:34:40
问题 I'm using NPOI to create fixed worksheet template in Sheet1, and need data from Sheet2 that's in date format.I generate DataTable from database to set data in Sheet2. It's my code : private DataTable getWeek() { strConn = WebConfigurationManager.ConnectionStrings["myConn"].ConnectionString; conn = new OdbcConnection(strConn); conn.Open(); sql = "SELECT week, sunday, saturday FROM tb_weekreferences"; da = new OdbcDataAdapter(sql, conn); dt = new DataTable(); da.Fill(dt); conn.Close(); return

NPOI Date Format Cell

孤街醉人 提交于 2021-02-07 03:21:37
问题 I'm using NPOI to create fixed worksheet template in Sheet1, and need data from Sheet2 that's in date format.I generate DataTable from database to set data in Sheet2. It's my code : private DataTable getWeek() { strConn = WebConfigurationManager.ConnectionStrings["myConn"].ConnectionString; conn = new OdbcConnection(strConn); conn.Open(); sql = "SELECT week, sunday, saturday FROM tb_weekreferences"; da = new OdbcDataAdapter(sql, conn); dt = new DataTable(); da.Fill(dt); conn.Close(); return

Reading mdy_hms AM/PM off excel into r

风流意气都作罢 提交于 2021-02-05 11:53:21
问题 I am using dplyr and lubridate. I am using read_excel to export a data.frame into R from excel. In Excel, I have a column that consists of mdy_hms AM or PM. In R, my code consists of: df$dateTimeEtc And this prints out as an example: "2017-03-07 11:10:37 UTC" "2017-03-22 10:04:42 UTC" "2017-03-08 09:36:49 UTC" However, I have tried to use: df <- df %>% mutate(dateTimeEtc = mdy_hms(dateTimeEtc)) So that R recognizes these data points in a mdy_hms (not sure what to do to include the AM/PM)

gnuplot: how to convert 12h time format into 24h time format?

。_饼干妹妹 提交于 2021-02-05 07:25:26
问题 How can I convert the annoying 12h time format (with AM and PM) into the 24h time format? I wanted to avoid external programs like awk as in this example. Since gnuplot has a time-specifier %p for "am" and "pm" (check help time_specifiers ), I thought it would be easy. But the following code does not give the correct result, but a warning message: warning: Bad time format in string Maybe, I'm using %p incorrectly? Code: ### change 12h time format to 24h format (does not give correct results)

Writing a formatted string to a file - Java

不想你离开。 提交于 2021-02-05 05:10:14
问题 I have a string that I format with the System.out.format() method, I do something like : System.out.format("I = %3d var = %9.6f", i, myVar); but when I try to write this formatted string into a file, I only get something like "java.io.PrintStream@84fc8d" in it. After looking into the documentation understood that this method is a little like System.out.print() and just return a PrintStream to display (in console for example), so I tried converting it with .toString or String.valueOf() but I

Convert a string to decimal in VB.NET

好久不见. 提交于 2021-02-04 17:16:40
问题 What will be the easiest way to convert a string to decimal? Input: a = 40000.00- Output will be 40,000.00- I tried to use this code: Dim a as string a = "4000.00-" a = Format$(a, "#,###.##") console.writeline (a) 回答1: Use Decimal.Parse to convert to decimal number, and then use .ToString("format here") to convert back to a string. Dim aAsDecimal as Decimal = Decimal.Parse(a).ToString("format here") Last resort approach (not recommended): string s = (aAsDecimal <0) ? Math.Abs(aAsDecimal)