Android Time Get Now(String time)

Here you can find the source of Now(String time)

Description

Now

Declaration

public static String Now(String time) 

Method Source Code

//package com.java2s;

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

public class Main {

    public static String Now(String time) {
        SimpleDateFormat formatter = new SimpleDateFormat(
                "yyyyMMdd  hhmmss");
        SimpleDateFormat formatter2 = new SimpleDateFormat(
                "yyyy-MM-dd  hh:mm:ss");
        Date curDate;/*from   w w w  .  j a va2s.com*/
        try {
            curDate = formatter.parse(time);
            return formatter2.format(curDate);
        } catch (ParseException e) {
            e.printStackTrace();
            return formatter2.format(System.currentTimeMillis());
        }
    }

    /**
     * 
     * @param src
     * @param objects
     * @return
     */
    public static String format(String src, Object... objects) {
        int k = 0;
        for (Object obj : objects) {
            src = src.replace("{" + k + "}", obj.toString());
            k++;
        }
        return src;
    }
}

Related

  1. getCurrentTime()
  2. toTime(int time)
  3. getCurrentTime()
  4. intConvertTime(int hour, int minut)
  5. getCurrentTime(String format)