Join the social network of Tech Nerds, increase skill rank, get work, manage projects...
 
  • How to to get date and time in diffrent formats in android?

    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 151
    Comment on it

    If you want to display date and time in multiple formats from your android device then here below given the methods to achieve it.

    // Type of format you want,
    String format="yyyy/MM/dd hh:mm:ss";
    String format2="yyyyMMdd hhmmss";
    String format1="yyyy-MM-dd hh:mm:ss";
    
    // Method to get date and time from android device.
    public static String getDateTime() 
        {
            DateFormat dateFormatter = new SimpleDateFormat("format");
            dateFormatter.setLenient(false);
            Date today = new Date();
            String s = dateFormatter.format(today);
            return s;
        }

 0 Comment(s)

Sign In
                           OR                           
                           OR                           
Register

Sign up using

                           OR                           
Forgot Password
Fill out the form below and instructions to reset your password will be emailed to you:
Reset Password
Fill out the form below and reset your password: