format

how to set the number format for an EditText

纵然是瞬间 提交于 2019-12-06 10:22:22
I want the number being displayed in my EditText upto 1 decimal place with no leading zeroes e.g. 25.0 not like 025.0 how can i do this? this is in android You can use DecimalFormat DecimalFormat format = new DecimalFormat("##.#"); String formattedText = format.format(025.0); editText.setText(formattedText); You will get result in EditText as 25.0 you can set it in xml file. Like <EditText android:id="@+id/editText1" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_alignLeft="@+id/imageView1" android:layout_below="@+id/imageView1" android:layout

python 2.7.5+ print list without spaces after the commas

做~自己de王妃 提交于 2019-12-06 10:17:16
问题 I do print [1,2] But I want the print to output in the format [1,2] without the extra space after the comma. Do I need some "stdout" function for this?` Python 2.7.5+ (default, Sep 19 2013, 13:48:49) [GCC 4.8.1] on linux2 回答1: The data in hand is a list of numbers. So, first we convert them to strings and then we join the join the strings with str.join function and then print them in the format [{}] using str.format, here {} represents the actual joined string. data = [1,2, 3, 4] print(data)

Hadoop 磁盘不足引发的一次“血案”

拟墨画扇 提交于 2019-12-06 09:13:29
笔者的hadoop在不间断的写文件的过程中报了如下错误 经查看发现是hadoop所在服务器的磁盘空间不足导致的。 好了,知道问题后笔者需要配置相关参数来避免该问题 1、与mapred.local.dir相关的参数 * mapred.local.dir.minspacestart:在mapreduce运行任务之前,检查temporary 目录下是否还有该选项配置的空闲空间,如果少于该配置,则map或reduce task不会分配到该TaskTracker上,以避免由于磁盘空间不足导致的task失败。默认设置为0,disable该功能 * mapred.local.dir.minspacekill:如果该磁盘卷下剩余的磁盘空间不足该配置,则将正在运行的Task 杀掉。默认为0,diabled该功能 另,如果服务器有多个块设备最好将mapred.local.dir设置成多个目录,每个目录对应一个块设备,这样多个task在同一个TaskTracker上运行的时候,就可以分别写不同的磁盘写入点,以增大作业运行的磁盘吞吐率。 2、与dfs.data.dir相关的参数 * dfs.datanode.du.reserved:dfs写文件块时,如果当前datanode上的dfs.data.dir下剩余磁盘空间不足该选项配置的空间大小,就不往该datanode继续写数据块 * dfs.datanode

Formattable based on multiple columns

时光总嘲笑我的痴心妄想 提交于 2019-12-06 08:54:49
问题 I am using the package formattable to generate a formatted table. I found a nice resource Formatting tables in R. But here the example of arrow formatting is based only on the specific column. My requirement is: Say I have from different cities, column A and B, where A has factors with two levels 'Number of Trees' and 'Pollution', while B is the percentage change of these YoY. So I want to format the Column B with a positive green arrow if there has an increase for Column A values being

invalid XML file?

北战南征 提交于 2019-12-06 08:31:27
I wrote the following file in Visual Studio 2008 as a new XML file, and it reports the following error. What is the error message about and why it is treated as a wrong format XML file? Here is the XML file and related error message. <?xml version="1.0" encoding="utf-8"?> <Foo>&#x2;</Foo> Error 1 Character ' ', hexadecimal value 0x2 is illegal in XML documents. XMLFile1.xml 2 6 Miscellaneous Files thanks in avdance, George Your problem is the reference to &#x02, which essentially is random binary data that can not be printed. This is not allowed in XML1.0 (it is in XML 1.1 and higher, but it's

how to load the private key from a .der file into java private key object

社会主义新天地 提交于 2019-12-06 08:08:56
I'm writing a java program to import private keys from files within the file system and make a private key object, using java... I could do it for files in .pem format but, with .der format, I had no idea what to do, since I couldnt firstly detect the algorithm used to generate the keys. within .pem files I could determine the algorithm from the header for PKCS#1 which have a header like -----BEGIN RSA PRIVATE KEY---- formats and used the bouncycastle pem reader for those in PKCS#8 which have a header -----BEGIN PRIVATE KEY----- but with those in .der format no idea :( also if anyone have an

Customize date format in C++

大兔子大兔子 提交于 2019-12-06 07:43:01
I have this function: void Log::Write(string logline){ //2011-10-12 13:07:40 correct format time_t rawtime; struct tm * timeinfo; time ( &rawtime ); timeinfo = localtime ( &rawtime ); m_stream.write( asctime (timeinfo), 24 ); m_stream << " - " << logline << std::endl; } The output is like this: Thu Oct 13 12:35:30 2011 but I wanna see the output like the comment section: 2011-10-12 13:07:40 How is it possible? It's very possible. Look at the manpage for strftime() . In this case, you'd want: void Log::Write(string line) { time_t rawtime; struct tm * timeinfo; char buffer [80]; time ( &rawtime

Masked input Plugin with date limit

谁说我不能喝 提交于 2019-12-06 06:51:40
问题 I use masked input on a input text field for a date in the MM/YYYY format. ( http://digitalbush.com/projects/masked-input-plugin/ ) My javascript code: jQuery(function($){ $(".date").mask("12/2099"); }); And HTML Code: <input type="text" class="date"> When I start to write something it take to the field the value 12/2099 and it's impossible to write other thing. If in javascript mask I write 99/9999, users could write date that is false ... so I don't what I have to do ? I want to users that

Change time format in Django Views

♀尐吖头ヾ 提交于 2019-12-06 05:32:54
问题 import datetime in my django views to save the time in database and now = datetime.datetime.now() when i am saving its value in database it returns something like 2013-04-28 22:54:30.223113 how can i remove 223113 from 2013-04-28 22:54:30.223113 part please suggest how can i do this ... 回答1: Set microsecond=0 . But I can not find this feature in documentation.' >>> now = datetime.datetime.now().replace(microsecond=0) >>> print now 2013-04-29 12:47:28 回答2: You should ideally be using datetime

Javascript get and format current date [duplicate]

 ̄綄美尐妖づ 提交于 2019-12-06 05:04:48
问题 This question already has answers here : Closed 7 years ago . Possible Duplicate: Formatting a date in JavaScript I need to show a current date in format like this (some examples): sep 10, 2012 nov 5, 2012 and so on. Using javascript I get a current date object var date = new Date(); what I need to do next? 回答1: you can use this. function dateTest(){ var d =new Date(); var month_name=new Array(12); month_name[0]="Jan" month_name[1]="Feb" month_name[2]="Mar" month_name[3]="Apr" month_name[4]=