Archive

Archive for April, 2016

VND currency format in Java?

April 24th, 2016 No comments

[code lang=java]
public class JavaApplication15 {

public static void main(String[] args) {
double price = 20000000;
Locale locale = new Locale("vi", "VN");
Currency currency = Currency.getInstance("VND");

DecimalFormatSymbols df = DecimalFormatSymbols.getInstance(locale);
df.setCurrency(currency);
NumberFormat numberFormat = NumberFormat.getCurrencyInstance(locale);
numberFormat.setCurrency(currency);
System.out.println("Formatted currency: " + numberFormat.format(price));

// System.out.println("CURRENCY SYMBOL = " + df.getCurrencySymbol());
// System.out.println("DECIMAL SEPARATOR = " + df.getDecimalSeparator());
// System.out.println("GROUP SEPARATOR = " + df.getGroupingSeparator());
// System.out.println("CURRENCY CODE = " + df.getInternationalCurrencySymbol());
// System.out.println("DECIMAL PLACE = " + numberFormat.getMaximumFractionDigits());
// String sLP = ((DecimalFormat) numberFormat).toLocalizedPattern();
}
}
[/code]

Categories: Java Tags:

One Button Has Multiple State

April 8th, 2016 No comments

When you use a button with Two states, you just simply use a variable as boolean type (True/False).

But when you need a button with multiple states, How to do this?

That’s very simple by using the following statement:

 

[code lang=cpp]
<br />int state = 0

yourClickEvent(){
state = (state + 1) % numberOfStateYouWant
}

[/code]

 

an Example when  numberOfStateYouWant = 3

drrg

 

Cheers.

Huy Nguyen

Categories: Algorithms, Tips & Tricks Tags:

New project for tutorials

April 3rd, 2016 No comments

Some screen shots for preview:

2016_04_03_22.53.362016_04_03_22.52.432016_04_03_22.53.002016_04_03_22.53.11

This project may be finish in next 3 months.

View on Github

 

Categories: Android Tags: