package com.myapp.test;
import java.util.Date;
import java.util.Formatter;
import java.util.Locale;
public class PrintStreamTestForFormatAndPrintf {
public static void main(String[] args) {
// format
double balance = 1234.56;
System.out.format("Balanceis $%,.2f", balance);
Date today = new Date();
System.out.format("\nToday is %TF %TT", today, today);
// Formatter Class
Formatter myUSformat = new Formatter();
Formatter myFRformat = new Formatter();
System.out.println("\nFormatter Class Useses");
String balUS = myUSformat.format("\nBalance is $%,6.2f", balance)
.toString();
String balFR = myFRformat.format(Locale.FRANCE, "\nBalance is $%,6.2f",
balance).toString();
System.out.println("US" + balUS);
System.out.println("FRANCE" + balFR);
}
}
import java.util.Date;
import java.util.Formatter;
import java.util.Locale;
public class PrintStreamTestForFormatAndPrintf {
public static void main(String[] args) {
// format
double balance = 1234.56;
System.out.format("Balanceis $%,.2f", balance);
Date today = new Date();
System.out.format("\nToday is %TF %TT", today, today);
// Formatter Class
Formatter myUSformat = new Formatter();
Formatter myFRformat = new Formatter();
System.out.println("\nFormatter Class Useses");
String balUS = myUSformat.format("\nBalance is $%,6.2f", balance)
.toString();
String balFR = myFRformat.format(Locale.FRANCE, "\nBalance is $%,6.2f",
balance).toString();
System.out.println("US" + balUS);
System.out.println("FRANCE" + balFR);
}
}