How to format a ZonedDateTime to a String?

I want to convert a ZonedDateTime to a String in the format of (“dd/MM/yyyy – hh:mm”). I know this is possible in Joda-Time other types, just using their toString(“dd/MM/yyyy – hh:mm”)….But this doesn’t work with ZonedDateTime.toString(). How can I format a ZonedDateTime to a String? EDIT: I tried to print the time in another timezone … Read more

String.format() and hex numbers in Java

I’m trying to figure out why String.format() is behaving the way it does. Context: Systems programming class, writing an assembler. There is a 5 character hex field in the object file, which I am creating from a value. Tried using: String.format(“%05X”, decInt); This works as intended for positive numbers (11 -> 0000B) However it fails … Read more

string in namespace std does not name a type

This may just be a simple mistake that I’m not seeing, but I think I’m simply doing something wrong. Don’t worry I’m not using namespace std in my header functions or anything which seemed to be this person’s issue [Question I read similar to mine][1] [1]: Why am I getting string does not name a … Read more

Case-insensitive string startswith in Python

Here is how I check whether mystring begins with some string: >>> mystring.lower().startswith(“he”) True The problem is that mystring is very long (thousands of characters), so the lower() operation takes a lot of time. QUESTION: Is there a more efficient way? My unsuccessful attempt: >>> import re; >>> mystring.startswith(“he”, re.I) False Answer You could use … Read more

Is there a function to split a string in PL/SQL?

I need to write a procedure to normalize a record that have multiple tokens concatenated by one char. I need to obtain these tokens splitting the string and insert each one as a new record in a table. Does Oracle have something like a “split” function? Answer There is apex_util.string_to_table – see my answer to … Read more

How to get the last five characters of a string using Substring() in C#?

I can get the first three characters with the function below. However, how can I get the output of the last five characters (“Three”) with the Substring() function? Or will another string function have to be used? static void Main() { string input = “OneTwoThree”; // Get first three characters string sub = input.Substring(0, 3); … Read more

A good way to make long strings wrap to newline?

In my project, I have a bunch of strings that are read in from a file. Most of them, when printed in the command console, exceed 80 characters in length and wrap around, looking ugly. I want to be able to have Python read the string, then test if it is over 75 characters in … Read more

How do I convert an Int to a String in C# without using ToString()?

Convert the following int argument into a string without using any native toString functionality. public string integerToString(int integerPassedIn){ //Your code here } Since everything inherits from Object and Object has a ToString() method how would you convert an int to a string without using the native ToString() method? The problem with string concatenation is that … Read more