format

How can I change the format of a date from the command line?

半世苍凉 提交于 2019-12-18 07:00:03
问题 What's the quickest way to convert a date in one format, say 2008-06-01 to a date in another format, say Sun 1st June 2008 The important bit is actually the 'Sun' because depending on the dayname, I may need to fiddle other things around - in a non-deterministic fashion. I'm running GNU bash, version 3.2.17(1)-release (i386-apple-darwin9.0). [Background: The reason that I want to do it from the command line, is that what I really want is to write it into a TextMate command... It's an annoying

MYSQL output in tree format OR Adding level (Parent-Child)

纵饮孤独 提交于 2019-12-18 06:57:18
问题 Below is what I have in my table. myTable ++++++++++++++++++++ Parent + Child ++++++++++++++++++++ C1 + G1 C1 + G2 C1 + G3 G3 + D1 G3 + D2 C1 + G4 G4 + D3 G4 + D4 C2 + G5 C2 + G6 C2 + G7 C2 + G8 ++++++++++++++++++++ What, I want is as below using MYSQL. C1 G1 G2 G3 D1 D2 G4 D3 D4 C2 G5 G6 G7 G8 Please let me know if this is possible in MYSQL. The output is something like TREE . Update 1 If I get new table like below is also fine so that I can use this example. ++++++++++++++++++++++++++++++++

How to pad a binary string with zeros?

℡╲_俬逩灬. 提交于 2019-12-18 05:50:16
问题 string binary = Convert.ToString(15, 2); Console.WriteLine("{0}", binary); Prints: 1111 I want it to print 00001000 Because the data type is of string and not integer I cannot do something like this: Console.WriteLine("{0:00000000}", binary); 回答1: Console.WriteLine( binary.PadLeft(8, '0')); 回答2: You can try this one: Convert.ToString(15, 2).PadLeft(8, '0'); It should give you 00001111 来源: https://stackoverflow.com/questions/7682628/how-to-pad-a-binary-string-with-zeros

Cant set Date Taken/DateTime tag using the ExifInterface in Android

随声附和 提交于 2019-12-18 04:54:28
问题 I've researched and tried numerous options to try and get this to work, but am not getting anywhere with this unfortunately. What I am trying to do is set the Date Taken tag (Tag_DateTime) in a JPEG's Exif data from within an Android app. I already have working code to set the Latitude and Longitute tags, but cannot for the life of me get the Date taken tag to set. Here is the code: SimpleDateFormat fmt_Exif = new SimpleDateFormat("yyyy:MM:dd HH:mm:ss"); try { ExifInterface exif = new

String formatting in Python version earlier than 2.6

♀尐吖头ヾ 提交于 2019-12-18 03:50:30
问题 When I run the following code in Python 2.5.2: for x in range(1, 11): print '{0:2d} {1:3d} {2:4d}'.format(x, x*x, x*x*x) I get: Traceback (most recent call last): File "<pyshell#9>", line 2, in <module> print '{0:2d} {1:3d} {2:4d}'.format(x, x*x, x*x*x) AttributeError: 'str' object has no attribute 'format' I don't understand the problem. From dir('hello') there is no format attribute. How can I solve this? 回答1: The str.format method was introduced in Python 3.0, and backported to Python 2.6

String formatting in Python version earlier than 2.6

血红的双手。 提交于 2019-12-18 03:49:05
问题 When I run the following code in Python 2.5.2: for x in range(1, 11): print '{0:2d} {1:3d} {2:4d}'.format(x, x*x, x*x*x) I get: Traceback (most recent call last): File "<pyshell#9>", line 2, in <module> print '{0:2d} {1:3d} {2:4d}'.format(x, x*x, x*x*x) AttributeError: 'str' object has no attribute 'format' I don't understand the problem. From dir('hello') there is no format attribute. How can I solve this? 回答1: The str.format method was introduced in Python 3.0, and backported to Python 2.6

How to use String.format() in Java to replicate tab “\t”?

无人久伴 提交于 2019-12-18 03:17:17
问题 I'm printing data line by line and want it to be organized like a table. I initially used firstName + ", " + lastName + "\t" + phoneNumber . But for some of the larger names, the phone number gets pushed out of alignment I'm trying to use String.format() to achieve this effect. Can anyone tell me the format syntax to use? I tried String.format("%s, %s, %20s", firstName, lastName, phoneNumber) , but that's not what I want. I want it to look like this: John, Smith 123456789 Bob, Madison

XSLT format-number with comma

孤人 提交于 2019-12-18 02:55:14
问题 I'm trying to format this and other elements alike, so it would look like this 2,590: <Add_Amount>2,59</Add_Amount> Doing it like this: <xsl:decimal-format name="dkk" decimal-separator="," grouping-separator="."/> .... <xsl:value-of select="translate(format-number(Add_Amount, '#.###,000', 'dkk'), ',', '.')" /> And the output comes out NaN. Any help is greatly appreciated. Thanks. //Daniel 回答1: Use : format-number(translate(., ',','.'), '#.###,000', 'd') This transformation : <xsl:stylesheet

How to know if now time is between two hours?

北城以北 提交于 2019-12-18 02:17:15
问题 I have a now time: new Date(); And I have some hour constants, for example, 23 and 8 (it's 11pm or 23:00, 8am or 08:00). How I can know is now time between it's two hour constants? It need to run some code of program or not to run if now time is between in two hours, for example, do not run some code if its already evening and while it is not a morning. Here the image to better explain: Some situations when silent mode does not fire: 00:00 20.06.13 - 23:00 20.06.13 // after 23.00 can loud!!

Nested Json to pandas DataFrame with specific format

空扰寡人 提交于 2019-12-17 22:36:04
问题 i need to format the contents of a Json file in a certain format in a pandas DataFrame so that i can run pandassql to transform the data and run it through a scoring model. file = C:\scoring_model\json.js (contents of 'file' are below) { "response":{ "version":"1.1", "token":"dsfgf", "body":{ "customer":{ "customer_id":"1234567", "verified":"true" }, "contact":{ "email":"mr@abc.com", "mobile_number":"0123456789" }, "personal":{ "gender": "m", "title":"Dr.", "last_name":"Muster", "first_name":