get current time in yyyy/MM/dd/ HH:mm format - Android java.util

Android examples for java.util:Date Format

Description

get current time in yyyy/MM/dd/ HH:mm format

Demo Code

import java.text.SimpleDateFormat;
import java.util.Date;

public class Main {

  public static String getData() {
    SimpleDateFormat formatter = new SimpleDateFormat("yyyy/MM/dd/ HH:mm");
    Date curDate = new Date(System.currentTimeMillis());
    String str = formatter.format(curDate);
    return str;//from   ww  w  .j  av  a  2 s . c o  m
  }

}

Related Tutorials