Convert time in long to specific date format – SimpleDateFormat in action!

Here is that pretty snippet for converting long to specific date format:

[java]public static String getDate(long milliSeconds, String dateFormat)
{
// Create a DateFormatter object for displaying date in specified format.
SimpleDateFormat formatter = new SimpleDateFormat(dateFormat);
// Create a calendar object that will convert the date and time value in milliseconds to date.
Calendar calendar = Calendar.getInstance();
calendar.setTimeInMillis(milliSeconds);
return formatter.format(calendar.getTime());
}[/java]

I took source from: http://stackoverflow.com/a/7954038/619673

Read more

Pretty nice decimal format for polish currencies

Here is the simple sample code which converts pretty nice for example polish currencies to float and from float to polish format.
These are the spoiler results:
[java]DecimalUtil.getInstance().parse(“1 123,44) -> 1123.44[/java]
[java]DecimalUtil.getInstance().format(1123.44) -> 1 123,44[/java]

Read more