get New Simple Date Format for Asia/Seoul - Android java.util

Android examples for java.util:Date Format

Description

get New Simple Date Format for Asia/Seoul

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 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;
    }//from w ww .  j  a v  a  2 s.  co m
}

Related Tutorials