I really need help, I am new to programming. Every time i run my code I get this problem Conversion = '-'.
Here is the code:
Her is the code for Product
public abstract class Product implements Comparable<Product>, Serializable{
private Discount dR;
private String description;
private double price;
private int numInStock;
private Date releaseDate;
private int rating;
public Product() {
}
And here is the code for Discount which is dR
public class Discount {
private Product pro;
private Customer cust;
private double price;
private int quantity;
private double getDiscount;
private char discountRate;
public Discount() {
super();
}
public String toStringD() {
NumberFormat nf = NumberFormat.getCurrencyInstance();
String string;
string = "ALL PRODUCT SOLD";
string = string + String.format("%-35s %-20d", description, dR.getQuantity()) +
"\t\t" + nf.format(price) + "\t" + String.format("%-15f %-15d", dR.getPrice(), releaseDate);
return string;
}
Here is the problem
java.util.UnknownFormatConversionException: Conversion = '-'
java.util.UnknownFormatConversionException: Conversion = '-'
is thrown when you try to format a string using a different type from the one that you declared in the string, ie: %d, %f, etc.
To corroborate this, i run your method in my ide changing the parameters in the string format functions for hardcoded params of the right type.
I could run your method without problems.
Therefore, either:
1) "description" is not a string. 2) dR.getQuantity() returns a float or other non-integer types. 3) dr.getPrice() doesn't return a float 4) releaseDate doesn't return an integer.
Since you didn't provide the rest of your code I can't tell you exactly which of these is giving you trouble, but I think that with this info you can track the variable that is giving you trouble.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.