public static void main(String[] args) throws UnsupportedEncodingException { final String text = "待加密文字"; final byte[] textByte = text.getBytes("UTF-8"); //编码 final String encodedText = Base64.encodeToString(textByte); //解码 String sdecode = new String(Base64.decode(encodedText), "UTF-8"); // url加密 String urlString = URLEncoder.encode(sdecode, "utf-8"); //输出%E4%BD%A0%E5%A5%BD //url解密 String keyWord = URLDecoder.decode(urlString, "utf-8"); System.out.println("Base64编码** " + encodedText); System.out.println("Base64解码** " + sdecode); System.out.println("url加密** " + urlString); System.out.println("url解密** " + keyWord); //获取当月第一天和最后一天 Calendar cal = Calendar.getInstance(); cal.setTime(new Date()); cal.set(Calendar.DAY_OF_MONTH, 1); System.out.println(new SimpleDateFormat("yyyy-MM-dd").format(cal.getTime())); cal.roll(Calendar.DAY_OF_MONTH, -1); System.out.println(new SimpleDateFormat("yyyy-MM-dd").format(cal.getTime())); //获取当月所有日期 List<String> list = new ArrayList<String>(); Calendar aCalendar = Calendar.getInstance(Locale.CHINA); int year = aCalendar.get(Calendar.YEAR);//年份 int month = aCalendar.get(Calendar.MONTH) + 1;//月份 int day = aCalendar.getActualMaximum(Calendar.DATE); for (int i = 1; i <= day; i++) { String aDate = String.valueOf(year) + "-" + month + "-" + i; list.add(aDate); } System.out.println(list); }