get Simple Date Format MMDD - Android java.util

Android examples for java.util:Date Format

Description

get Simple Date Format MMDD

Demo Code


//package com.java2s;

import java.text.SimpleDateFormat;
import java.util.Calendar;

import java.util.Locale;
import java.util.TimeZone;
import android.text.TextUtils;

public class Main {
    private static SimpleDateFormat sdf;
    private static Calendar calendar;

    public static String getSimpleDateFormatMMDD(String time) {

        String mTime = "";

        mTime = getNewSimpleDateFormat("MM? dd???", time);

        return mTime;
    }//from ww w  . ja v  a 2s  . c om

    public static String getNewSimpleDateFormat(String pattern, String time) {

        String mTime = "";

        if (TextUtils.isEmpty(pattern) || TextUtils.isEmpty(time))
            return mTime;

        sdf = new SimpleDateFormat(pattern, Locale.KOREA);
        sdf.setTimeZone(TimeZone.getTimeZone("Asia/Seoul"));

        calendar = Calendar.getInstance();
        calendar.setTimeZone(sdf.getTimeZone());
        calendar.setTimeInMillis(Long.parseLong(time) * 1000L);

        mTime = sdf.format(calendar.getTime());
        return mTime;
    }
}

Related Tutorials