Format date to Hyphenated String - Android java.util

Android examples for java.util:Date Format

Description

Format date to Hyphenated String

Demo Code

import java.util.Calendar;

import android.text.format.DateFormat;

public class Main {

  public static String toHyphenatedString(int year, int monthOfYear, int day) {
    Calendar calendar = Calendar.getInstance();
    calendar.set(year, monthOfYear, day);
    return DateFormat.format("yyyy-MM-dd", calendar).toString();
  }// www  . ja  v a 2 s . c  o  m

}

Related Tutorials