converts Calendar to something like 6/20/2016 05:00:00 AM - Android java.util

Android examples for java.util:Date Convert

Description

converts Calendar to something like 6/20/2016 05:00:00 AM

Demo Code


//package com.java2s;

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

import java.util.TimeZone;

public class Main {
    /**/*  w ww. j av  a 2  s .  c om*/
     * converts to something like 6/20/2016 05:00:00 AM
     */
    public static String convertToBackendTime2(Calendar time) {
        SimpleDateFormat formatter = new SimpleDateFormat("MM-dd-yyyy");
        formatter.setTimeZone(TimeZone.getTimeZone("GMT"));
        return formatter.format(time.getTime());
    }
}

Related Tutorials