How to get the given date string format(pattern) in java?

import java.text.ParseException; import java.text.SimpleDateFormat; import java.util.Date; import java.util.regex.Matcher; import java.util.regex.Pattern; public class NewClass { private static final String[] formats = { “yyyy-MM-dd’T’HH:mm:ss’Z'”, “yyyy-MM-dd’T’HH:mm:ssZ”, “yyyy-MM-dd’T’HH:mm:ss”, “yyyy-MM-dd’T’HH:mm:ss.SSS’Z'”, “yyyy-MM-dd’T’HH:mm:ss.SSSZ”, “yyyy-MM-dd HH:mm:ss”, “MM/dd/yyyy HH:mm:ss”, “MM/dd/yyyy’T’HH:mm:ss.SSS’Z'”, “MM/dd/yyyy’T’HH:mm:ss.SSSZ”, “MM/dd/yyyy’T’HH:mm:ss.SSS”, “MM/dd/yyyy’T’HH:mm:ssZ”, “MM/dd/yyyy’T’HH:mm:ss”, “yyyy:MM:dd HH:mm:ss”, “yyyyMMdd”, }; /* * @param args */ public static void main(String[] args) { String yyyyMMdd = “20110917”; parse(yyyyMMdd); … Read more

Changing the date format to yyyy-mm-dd

UPDATED: NEW ANSWER Here is a solution that will do the job! The sub routine includes a function that does the replacement (the function itself is really useful!). Run the sub and all occurances in column A will be fixed. Sub FixDates() Dim cell As range Dim lastRow As Long lastRow = range(“A” & Rows.count).End(xlUp).Row … Read more

How to create variable argument methods in Objective-C

What these are called, generally, is “variadic functions” (or methods, as it were). To create this, simply end your method declartion with , …, as in – (void)logMessage:(NSString *)message, …; At this point you probably want to wrap it in a printf-like function, as implementing one of those from scratch is trying, at best. – … Read more

Parse C# string to DateTime

Absolutely. Guessing the format from your string, you can use ParseExact string format = “ddMMyyyyHHmm”; DateTime dt = DateTime.ParseExact(value, format, CultureInfo.InvariantCulture); or TryParseExact: DateTime dt; bool success = DateTime.TryParseExact(value, format, CultureInfo.InvariantCulture, DateTimeStyles.None, out dt); The latter call will simply return false on parse failure, instead of throwing an exception – if you may have bad … Read more

Convert a String to Double – Java

Have a look at java.text.NumberFormat. For example: import java.text.*; import java.util.*; public class Test { // Just for the sake of a simple test program! public static void main(String[] args) throws Exception { NumberFormat format = NumberFormat.getInstance(Locale.US); Number number = format.parse(“835,111.2”); System.out.println(number); // or use number.doubleValue() } } Depending on what kind of quantity you’re … Read more