get Date YYYYMMDD in Asia/Seoul - Android java.util

Android examples for java.util:Date Format

Description

get Date YYYYMMDD in Asia/Seoul

Demo Code


//package com.java2s;

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

import java.util.Locale;
import java.util.TimeZone;

public class Main {
    public static String getDateYYYYMMDD(int gap) {

        Calendar cal = Calendar.getInstance();

        cal.add(cal.DATE, gap);/*  w w  w  .j a v  a 2 s.com*/

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

        return dateFormat.format(cal.getTime());
    }
}

Related Tutorials