Main.java Source code

Java tutorial

Introduction

Here is the source code for Main.java

Source

//package com.java2s;
import java.util.Calendar;

import android.content.Context;
import android.content.SharedPreferences;

import android.preference.PreferenceManager;

public class Main {
    public static Calendar getWallpaperDate(Context context) {
        Calendar wallpaperDate = Calendar.getInstance();

        SharedPreferences preferences = PreferenceManager.getDefaultSharedPreferences(context);
        String dateTimeToString = preferences.getString("wallpaper_date", null);
        if (dateTimeToString == null)
            return wallpaperDate;

        wallpaperDate.set(Calendar.YEAR, Integer.parseInt(dateTimeToString.split("/")[0]));
        wallpaperDate.set(Calendar.MONTH, Integer.parseInt(dateTimeToString.split("/")[1]));
        wallpaperDate.set(Calendar.DATE, Integer.parseInt(dateTimeToString.split("/")[2]));

        return wallpaperDate;
    }
}