JAVA 日期类型是String YYYYMM取下一个月的第一天
1个回答
展开全部
package test;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Calendar;
import java.util.Date;
public class YuGiOh
{
private static String convert ( String source )
{
try
{
SimpleDateFormat sdf = new SimpleDateFormat ("yyyyMM");
SimpleDateFormat sdf2 = new SimpleDateFormat ("yyyy-MM-dd HH:mm:ss");
Date date = sdf.parse (source);
Calendar calendar = Calendar.getInstance ();
calendar.setTime (date);
calendar.add (Calendar.MONTH, 1);
return sdf2.format (calendar.getTime ());
}
catch (ParseException e)
{
e.printStackTrace ();
}
return "";
}
public static void main ( String[] args )
{
String result = convert ("201503");
System.out.println (result);
}
}
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询