Android中的每月订阅

时间:2013-10-24 08:12:41

标签: android date calendar

我是Android的新手,我开发了一个应用程序,现在我想申请每月订阅,我必须跟踪日期,我已经尝试了以下代码

try {
            before = (Date)formatter.parse(date);


        } catch (ParseException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        }
        Date now = new Date();

        long diff = now.getTimeInMillis() - before.getTimeInMillis();
        long days = diff / ONE_DAY;
        if(days > 30) { // More than 30 days?
             // Expired !!!
        }

它给出了错误     long diff = now.getTimeInMillis() - before.getTimeInMillis();

那么请你告诉我这是什么选择?

1 个答案:

答案 0 :(得分:0)

您可以从日历中获取日期:

Calendar c = Calendar.getInstance(); 
int seconds = c.get(Calendar.SECOND);

您可以从Calendar获得许多其他常量。

检查Calendar documentation输出。