NumberFormatException while parsing date with SimpleDateFormat.parse()

The likely cause is the fact that SimpleDateFormat isn’t threadsafe, and you’re referencing it from multiple threads. While extremely difficult to prove (and about as hard to test for), there is some evidence this is the case: .11331133EE22 – notice how everything is doubled 880044E.3880044E3 – same here You probably have at least two threads … Read more

How to Convert date into MM/DD/YY format in C#

DateTime.Today.ToString(“MM/dd/yy”) Look at the docs for custom date and time format strings for more info. (Oh, and I hope this app isn’t destined for other cultures. That format could really confuse a lot of people… I’ve never understood the whole month/day/year thing, to be honest. It just seems weird to go “middle/low/high” in terms of … Read more

Declare a TDateTime as a Const in Delphi

Ok, my reaction is a bit late, but here’s a solution for the newer Delphi’s. It uses implicit class overloaders so that records of this type can be used as if they are TDateTime variables. TDateRec = record year,month,day,hour,minute,second,millisecond:word; class operator implicit(aDateRec:TDateRec):TDateTime; class operator implicit(aDateTime:TDateTime):TDateRec; // not needed class operator implicit(aDateRec:TDateRec):String; // not needed class … Read more

Java String to Date object of the format “yyyy-mm-dd HH:mm:ss”

java.util.Date temp = new SimpleDateFormat(“yyyy-MM-dd HH:mm:ss.SSSSSS”).parse(“2012-07-10 14:58:00.000000”); The mm is minutes you want MM CODE public class Test { public static void main(String[] args) throws ParseException { java.util.Date temp = new SimpleDateFormat(“yyyy-MM-dd HH:mm:ss.SSSSSS”) .parse(“2012-07-10 14:58:00.000000”); System.out.println(temp); } } Prints: Tue Jul 10 14:58:00 EDT 2012

get time and date by NSDate

NSDate *localDate = [NSDate date]; NSDateFormatter *dateFormatter = [[NSDateFormatter alloc]init]; dateFormatter.dateFormat = @”MM/dd/yy”; NSString *dateString = [dateFormatter stringFromDate: localDate]; NSDateFormatter *timeFormatter = [[NSDateFormatter alloc]init]; timeFormatter.dateFormat = @”HH:mm:ss”; NSString *dateString = [timeFormatter stringFromDate: localDate]; There are many many different ways to represent the date and time so check NSDateFormatter for more info.