Subversion Repositories SmartDukaan

Rev

Rev 2141 | Go to most recent revision | Details | Last modification | View Log | RSS feed

Rev Author Line No. Line
2137 chandransh 1
package in.shop2020.serving.utils;
2
 
3
import in.shop2020.model.v1.user.Cart;
4
import in.shop2020.model.v1.user.UserContextService;
5
import in.shop2020.thrift.clients.UserContextServiceClient;
6
 
7
import java.text.DecimalFormat;
8
import java.text.NumberFormat;
9
import java.util.Locale;
10
 
11
public class FormattingUtils {
12
 
13
	private static Locale indianLocale = new Locale("en", "IN");
14
 
15
	private NumberFormat currencyFormat;
16
 
17
	public FormattingUtils(){
18
		currencyFormat = NumberFormat.getNumberInstance(indianLocale);
19
		currencyFormat.setMaximumFractionDigits(2);
20
		currencyFormat.setMinimumFractionDigits(2);
21
		currencyFormat.setMinimumIntegerDigits(1);
22
	}
23
 
24
	public String formatPrice(double amount){
25
		return currencyFormat.format(amount);
26
	}
27
 
28
	public static void main(String[] args) throws Exception{
29
		FormattingUtils formattingUtils = new FormattingUtils();
30
		UserContextServiceClient client = new UserContextServiceClient();
31
		Cart cart = client.getClient().getCart(93439);
32
		double amount = cart.getTotalPrice();
33
		System.out.println(amount);
34
		System.out.println(formattingUtils.formatPrice(amount));
35
	}
36
}