Android source code from + Notepad++ with regex

Did You have problem with copying text from grepcode? Did You have problem with a lot spaces and wrong formatting?
Well it is possible to reformat that text with two commands using regex in notepad.

Let’s say we have this:



public void [More ...] setButtonDrawable(int resid) {


if (resid != 0 && resid == mButtonResource) {





It is possible to convert original source to better format like this:

public void setButtonDrawable(int resid) {
if (resid != 0 && resid == mButtonResource) {
mButtonResource = resid;
Drawable d = null;
if (mButtonResource != 0) {
d = getResources().getDrawable(mButtonResource);


You have to paste Your selected code to Notepad++, then click CTRL+H (for replacing function). Select at the bottom option for regex. And finally make two replacing steps:
1. replace from \d+\s+\r\n to (empty text here)
1. replace from ^[\s+][\r\n$] to (empty text here)

And that’s it!

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

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

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();
return formatter.format(calendar.getTime());

I took source from:

Continue reading “Convert time in long to specific date format – SimpleDateFormat in action!”

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:
DecimalUtil.getInstance().parse("1 123,44) -> 1123.44
DecimalUtil.getInstance().format(1123.44) -> 1 123,44

Continue reading “Pretty nice decimal format for polish currencies”