/*
 * Created on 2005-7-7
 *
 * TODO To change the template for this generated file go to
 * Window - Preferences - Java - Code Style - Code Templates
 *//**
 * @author leilei
 *
 * TODO To change the template for this generated type comment go to
 * Window - Preferences - Java - Code Style - Code Templates
 */
import java.util.Calendar;
import javax.swing.JOptionPane;
import java.text.SimpleDateFormat;
public class FormateDateOutput
{
private int year;
public static void main (String [] args)
{
String input = JOptionPane.showInputDialog("请输入有效的年份(YYYY):");
int year1 =Integer.parseInt(input);
FormateDateOutput out =new FormateDateOutput();
out.setYear(year1);
if(year1 !=0&&input.length()==4)

out.FormateDateStr();
}
else
{
System.out.println("输入的年份无效。");
}
System.exit(0);}
public void FormatDateStr()
{

SimpleDateFormat formatter =
(SimpleDateFormat)SimpleDateFormat.getDateInstance();
formatter.applyPattern("yyyy-mm-dd");
Calendar ca1 =Calendar.getInstance();for( int i=0;i<12;i++)
{
ca1.set(year,i,1);
int temp =ca1.getActualMaximum(Calendar.DAY_OF_MONTH);
for (int j=1;j<=temp;j++)
{
ca1.set(year,i,j);
String str = formatter.format(ca1.getTime());
System.out.println("当前时间是:"+str);
}
}
}public void setYear(int year)
{
this.year =year;
}
}
错误提示:Exception in thread "main" java.lang.Error: Unresolved compilation problems: 
FormateDateOutput cannot be resolved or is not a type
The method FormateDateStr() is undefined for the type FormateDateoutput at Date.main(Date.java:24)

解决方案 »

  1.   

    hehe.---------
    import java.util.*;
    import java.io.*;import java.util.Calendar;
    import javax.swing.JOptionPane;
    import java.text.SimpleDateFormat;public class FormateDateOutput {
        private int year;    public static void main(String[] args) {
            String input = JOptionPane.showInputDialog("请输入有效的年份(YYYY):");
            int year1 = Integer.parseInt(input);
            FormateDateOutput out = new FormateDateOutput();
            out.setYear(year1);
            if (year1 != 0 && input.length() == 4) {
                out.FormatDateStr();
            } else {
                System.out.println("输入的年份无效。");
            }
            System.exit(0);    }    public void FormatDateStr() {        SimpleDateFormat formatter = (SimpleDateFormat) SimpleDateFormat
                    .getDateInstance();
            formatter.applyPattern("yyyy-mm-dd");
            Calendar ca1 = Calendar.getInstance();        for (int i = 0; i < 12; i++) {
                ca1.set(year, i, 1);
                int temp = ca1.getActualMaximum(Calendar.DAY_OF_MONTH);
                for (int j = 1; j <= temp; j++) {
                    ca1.set(year, i, j);
                    String str = formatter.format(ca1.getTime());
                    System.out.println("当前时间是:" + str);
                }
            }
        }    public void setYear(int year) {
            this.year = year;
        }
    }
      

  2.   

    out.FormateDateStr();没有这个方法,
    你自己定义的方法少了一个e,嘿嘿。
      

  3.   

    out.FormateDateStr();

    out.FormatDateStr();
      

  4.   

    public void FormateDateStr()