Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/date/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
android日期格式时间戳输出为"/日期(1393346946000+;0200)/_Android_Date_Timestamp - Fatal编程技术网

android日期格式时间戳输出为"/日期(1393346946000+;0200)/

android日期格式时间戳输出为"/日期(1393346946000+;0200)/,android,date,timestamp,Android,Date,Timestamp,我想按以下格式转换当前时间: “/日期(139334694600+0200)/ 我该怎么做 public static Date getCurrentTime() { Calendar c = Calendar.getInstance(); System.out.println("Current time => " + c.getTimeInMillis()); long time = (System.currentTimeMillis()

我想按以下格式转换当前时间:

“/日期(139334694600+0200)/

我该怎么做

 public static Date getCurrentTime() {
        Calendar c = Calendar.getInstance();
        System.out.println("Current time => " + c.getTimeInMillis());
        long time = (System.currentTimeMillis());

        System.out.println("Current time2 => " + time);
        Date currentTime = c.getTime();
        return
                currentTime;

    }

使用此选项可将当前时间设置为所需格式

String inputPattern = "yyyy-MM-dd hh:mm:ss";
    String outputPattern = "dd/MM";//here you can give your output format that's all

    SimpleDateFormat inFormat = new SimpleDateFormat(inputPattern);
    SimpleDateFormat outputFormat = new SimpleDateFormat(outputPattern);
    Date date1 = null;

    if (date != null) {
        try {
            date1 = inFormat.parse(date);
            str = outputFormat.format(date1);
            Log.d(null, str);
        } catch (ParseException e) {
            e.printStackTrace();
        }

    } else {
        str = " ";
    }