public static String convertStringToCurrency(String amount) {
NumberFormat currencyFormat = NumberFormat.getCurrencyInstance(Locale.US);
String amountConverted = currencyFormat.format(Double.parseDouble(amount));
return amountConverted;
}
public static String convertStringFormattedToCurrency(String amount) {
NumberFormat currencyFormat = NumberFormat.getCurrencyInstance(Locale.US);
String amountConverted = currencyFormat.format(Double.parseDouble(amount.toString().replaceAll(",", "")));
return amountConverted;
}
public static String convertLongToTimestampDisplayformat(Long jsonDate) throws ParseException {
Timestamp ts = new Timestamp(jsonDate);
String oldDate = ts.toString();
SimpleDateFormat formatter, FORMATTER;
formatter = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss.SSS");
FORMATTER = new SimpleDateFormat("MM/dd/yyyy HH:mm:ss.SSS");
Date newDateFormat = formatter.parse(oldDate);
return FORMATTER.format(newDateFormat);
}
public static String convertAmountToReportFormat(String amount) throws ParseException {
//amount ="";
double parsedAmount = Double.parseDouble(amount.replaceAll("[^.\\dE-]", ""));
return String.format("%.2f",parsedAmount);
}
public static String convertPhoneToReportFormat(String phone) throws ParseException {
//amount ="";
String parsedPhoneNumber = phone.replaceAll("[^\\d]", "");
return parsedPhoneNumber;
}
NumberFormat currencyFormat = NumberFormat.getCurrencyInstance(Locale.US);
String amountConverted = currencyFormat.format(Double.parseDouble(amount));
return amountConverted;
}
public static String convertStringFormattedToCurrency(String amount) {
NumberFormat currencyFormat = NumberFormat.getCurrencyInstance(Locale.US);
String amountConverted = currencyFormat.format(Double.parseDouble(amount.toString().replaceAll(",", "")));
return amountConverted;
}
public static String convertLongToTimestampDisplayformat(Long jsonDate) throws ParseException {
Timestamp ts = new Timestamp(jsonDate);
String oldDate = ts.toString();
SimpleDateFormat formatter, FORMATTER;
formatter = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss.SSS");
FORMATTER = new SimpleDateFormat("MM/dd/yyyy HH:mm:ss.SSS");
Date newDateFormat = formatter.parse(oldDate);
return FORMATTER.format(newDateFormat);
}
public static String convertAmountToReportFormat(String amount) throws ParseException {
//amount ="";
double parsedAmount = Double.parseDouble(amount.replaceAll("[^.\\dE-]", ""));
return String.format("%.2f",parsedAmount);
}
public static String convertPhoneToReportFormat(String phone) throws ParseException {
//amount ="";
String parsedPhoneNumber = phone.replaceAll("[^\\d]", "");
return parsedPhoneNumber;
}
No comments:
Post a Comment