java Calendar类
程序员文章站
2022-06-22 07:55:57
public class CalendarDemo { public static void main(String[] args) { Date d = new Date(); SimpleDateFormat sdf = new SimpleDateFormat("yyyy"); String ......
public class calendardemo { public static void main(string[] args) { date d = new date(); simpledateformat sdf = new simpledateformat("yyyy"); string year = sdf.format(d); system.out.println(year); calendar c = calendar.getinstance(); //可以使用查表法月份查询 system.out.println(c.get(calendar.year)+"年"+(c.get(calendar.month)+1)+"月"+c.get(calendar.day_of_month)+"日"); } }
public class calendardemo { public static void main(string[] args) { calendar c = calendar.getinstance(); c.set(2012,2,23); system.out.println(c.get(calendar.year)+"年"+(c.get(calendar.month)+1)+"月"+c.get(calendar.day_of_month)+"日"); c.add(calendar.year,-4); system.out.println(c.get(calendar.year)+"年"+(c.get(calendar.month)+1)+"月"+c.get(calendar.day_of_month)+"日"); } }
下一篇: python中操作文件和目录