巧用Java的Calendar & Sqlite Developer破解

来源:互联网 发布:淘宝天机平台不让申请 编辑:程序博客网 时间:2024/05/17 03:29

     今天有个替代办法可以绕开数据库查询:知道当前时间点,向前推1年,然后将这个时间段内的年月遍历出来,按照特定格式拼成一个字符串。出现在自己头脑中的解决办法有几种,1.直接分支判断,对年、月进行极限边界设定、、但是我心里明白,这绝不是最佳实现! 2.用Java特有的实现类,查了查API文档,也就只有calendar能解决了。

package com.broad.test;import java.text.SimpleDateFormat;import java.util.Calendar;public class GetYearMonthArrays {public static void main(String[] args) {getYearMonthArr(Calendar.getInstance(), 24, "yyyy/MM");}public static String[] getYearMonthArr(Calendar calendar, int timeNum, String timeFormat) {SimpleDateFormat format = new SimpleDateFormat(timeFormat);//"yyyy/MM"String []yearMonthArr = new String[timeNum];for(int i = 0; i < timeNum; i++) {//timeNum = 12;calendar.add(Calendar.MONTH, -1);System.out.println(format.format(calendar.getTime()));yearMonthArr[i] = format.format(calendar.getTime());}return yearMonthArr;}}

输出结果:

2013/08
2013/07
2013/06
2013/05
· · · · ··

· · · ·· ·

2011/12
2011/11
2011/10
2011/09

即要求就是这样,输出当前时间点距离向前推1年、2年的特定年月格式字符串数组, 目的达到,输出结果如上。

Sqlite Developer破解【原理-删除其注册表】:
1.开始-运行-RegEdit-回车;
2.删除注册表文件 - HKEY_CURRENT_USER - SharpPlus - SqliteDev;

原创粉丝点击