import java.text.DecimalFormat;
//生成插入语句的java程序应用于商品日期表(版本2)
public class demo2 {
public static void main(String[] args) {
//把商品的productid抽出单写,减少修改,加快insert的生成效率
String month = "3";
//五月
for (int i=1;i<=31;i++){
double a=Math.random()*1000;
DecimalFormat df = new DecimalFormat( "0.00" );
String str=df.format( a );
System.out.println("INSERT INTO `productdate` VALUES ('20210500"+month+i+"', '"+month+"', '2021-05-"+i+"', "+str+", 1);");
}
//六月
for (int i=1;i<=30;i++){
double a=Math.random()*1000;
DecimalFormat df = new DecimalFormat( "0.00" );
String str=df.format( a );
System.out.println("INSERT INTO `productdate` VALUES ('20210600"+month+i+"', '"+month+"', '2021-06-"+i+"', "+str+", 1);");
}
//七月
for (int i=1;i<=31;i++){
double a=Math.random()*1000;
DecimalFormat df = new DecimalFormat( "0.00" );
String str=df.format( a );
System.out.println("INSERT INTO `productdate` VALUES ('20210700"+month+i+"', '"+month+"', '2021-07-"+i+"', "+str+", 1);");
}
//八月
for (int i=1;i<=31;i++){
double a=Math.random()*1000;
DecimalFormat df = new DecimalFormat( "0.00" );
String str=df.format( a );
System.out.println("INSERT INTO `productdate` VALUES ('20210800"+month+i+"', '"+month+"', '2021-08-"+i+"', "+str+", 1);");
}
//九月
for (int i=1;i<=30;i++){
double a=Math.random()*1000;
DecimalFormat df = new DecimalFormat( "0.00" );
String str=df.format( a );
System.out.println("INSERT INTO `productdate` VALUES ('20210900"+month+i+"', '"+month+"', '2021-09-"+i+"', "+str+", 1);");
}
//十月
for (int i=1;i<=31;i++){
double a=Math.random()*1000;
DecimalFormat df = new DecimalFormat( "0.00" );
String str=df.format( a );
System.out.println("INSERT INTO `productdate` VALUES ('20211000"+month+i+"', '"+month+"', '2021-10-"+i+"', "+str+", 1);");
}
}
}