get Date Time by locale and timezone - Android java.util

Android examples for java.util:Timezone

Description

get Date Time by locale and timezone

Demo Code

import java.text.SimpleDateFormat;
import java.util.Calendar;
import java.util.Date;
import java.util.HashMap;
import java.util.Locale;
import java.util.TimeZone;

public class Main{

    public static int getDateTime(int calendarType) {
        TimeZone timeZone = TimeZone.getTimeZone("GMT+8");
        Calendar calendar = Calendar.getInstance(timeZone, Locale.CHINESE);
        int date = calendar.get(calendarType);
        return date;
    }// w w  w .  ja  va  2 s .  c o m

}

Related Tutorials