zoukankan      html  css  js  c++  java
  • android 获取日期





    */ public static HashMap<String, String> computeDate(){ Calendar cal =Calendar.getInstance(); SimpleDateFormat df = new SimpleDateFormat("yyyy-MM-dd"); HashMap<String, String> map = new HashMap<String, String>(); cal.set(Calendar.DAY_OF_WEEK, Calendar.MONDAY); //获取本周一的日期 // System.out.println(df.format(cal.getTime())); map.put("MONDAY", df.format(cal.getTime())); cal.set(Calendar.DAY_OF_WEEK, Calendar.TUESDAY); //获取本周二的日期 // System.out.println(df.format(cal.getTime())); map.put("TUESDAY", df.format(cal.getTime())); cal.set(Calendar.DAY_OF_WEEK, Calendar.WEDNESDAY); //获取本周三的日期 // System.out.println(df.format(cal.getTime())); map.put("WEDNESDAY", df.format(cal.getTime())); cal.set(Calendar.DAY_OF_WEEK, Calendar.THURSDAY); //获取本周四的日期 // System.out.println(df.format(cal.getTime())); map.put("THURSDAY", df.format(cal.getTime())); cal.set(Calendar.DAY_OF_WEEK, Calendar.FRIDAY); //获取本周五的日期 // System.out.println(df.format(cal.getTime())); map.put("FRIDAY", df.format(cal.getTime())); cal.set(Calendar.DAY_OF_WEEK, Calendar.SATURDAY); //获取本周六的日期 // System.out.println(df.format(cal.getTime())); map.put("SATURDAY", df.format(cal.getTime())); //这种输出的是上个星期周日的日期,因为老外那边把周日当成第一天 cal.set(Calendar.DAY_OF_WEEK, Calendar.SUNDAY); //增加一个星期,才是我们中国人理解的本周日的日期 cal.add(Calendar.WEEK_OF_YEAR, 1); // System.out.println(df.format(cal.getTime())); map.put("SUNDAY", df.format(cal.getTime())); return map; }

      

  • 相关阅读:
    pip 最新版 发布(Python包安装和管理工具)
    Python使用cookie 免密登录了解一下
    夯实根基,必知必会的 Python 基础知识
    10个关于文件操作的小功能,都很实用~
    总结一些网站加密和混淆技术
    接口加密如何测试?
    艰难的这年,程序员的未来在哪里?
    警惕“职场PUA”!
    Python面试题及答案汇总
    Python实例练手项目汇总(附源码)
  • 原文地址:https://www.cnblogs.com/tefcricul/p/3667915.html
Copyright © 2011-2022 走看看