简单的日期处理方法

xiaoxiao2024-12-20  11

public class WeekOfMonth { /** * @param args */ public static void main(String[] args) { String str = "2008-10-12"; SimpleDateFormat formatter = new SimpleDateFormat("yyyy-MM-dd"); Calendar calendar = Calendar.getInstance(); try { calendar.setTime(formatter.parse(str)); } catch (ParseException e) { // TODO Auto-generated catch block e.printStackTrace(); } System.out.println(calendar.get(Calendar.WEEK_OF_MONTH )); SimpleDateFormat df = new SimpleDateFormat("dd"); String s = df.format(new Date()); System.out.println(s); String lastday = "2008-10-31"; String aa = lastday.substring(8, 10); System.out.println(aa); } }
转载请注明原文地址: https://www.6miu.com/read-5021596.html

最新回复(0)