Format date in MMM d, yyyy '@' HH:mm format - Android java.util

Android examples for java.util:Date Time

Description

Format date in MMM d, yyyy '@' HH:mm format

Demo Code

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

public class Main {

  /** E.g. Jul 2, 2018 @ 22:34 **/
  public static String getDate(long ms) {
    Date date = new Date(ms);
    SimpleDateFormat sdf = new SimpleDateFormat("MMM d, yyyy '@' HH:mm", Locale.ENGLISH);

    // The timezone on the website is at GMT
    sdf.setTimeZone(TimeZone.getTimeZone("GMT"));

    return sdf.format(date);
  }/*  w  w  w  .jav  a2  s.c o m*/

}

Related Tutorials