/*
* 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)
* 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)
解决方案 »
- 使用socket传送文件时,如何把文件名和文件类型也通过socket传送给服务器?
- 如何使用starUml的逆向工程将java代码转换成图形呢?
- 有没有支持Oracle 10G版的Toda
- java中有没有提供专门的排序类呢?除Collections类
- 判定在文本框输入正规邮件地址
- 发邮件的问题
- 如何对应用程序创建运行配置(在Jbuilder中)?(初学JAVA,谢谢)
- 如何在Applet中执行EXE文件?
- 救救我吧(访问数据库的中文问题)
- 大家救命啊,在一个frame中怎么控制另外一个frame里面的文本控件的内容!!!
- 有没有用jtable实现数据库信息的增删改的例子啊
- 请问如何得知调用栈?
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;
}
}
你自己定义的方法少了一个e,嘿嘿。
改
out.FormatDateStr();