String date into Epoch time

后端 未结 4 1925
闹比i
闹比i 2020-12-07 06:44

I am little bit confused in dates. I am currently working on the weather app and everything works fine .. I just wanna handle this type of format into my own desirable forma

4条回答
  •  遥遥无期
    2020-12-07 06:56

        String time_at_which_weather_capture = "Time : ";
    
    
        DateFormat dateFormat = new SimpleDateFormat("EEE,d M yyyy h:MM a");
        long timeInMillieSec = 0 ;
        try {
            Date date = dateFormat.parse(readyToUpdate.getTime());
            timeInMillieSec = date.getTime();
    
        } catch (ParseException e) {
            e.printStackTrace();
        }
       time.setText(time_at_which_weather_capture + String.valueOf(time_fetcher(timeInMillieSec)));
    
    
    
    public String time_fetcher (long time_coming_to_its_original_form) {
    
        Date date = new Date (time_coming_to_its_original_form);
        SimpleDateFormat sdf = new SimpleDateFormat("EEE, d M yyyy h:MM a");
        return sdf.format(date);
    
    
    
    }
    

提交回复
热议问题