本文介绍了获得Android的格式化的日期和时间的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有两个函数来计算的日期和时间。
I have two function to calculate date and time.
public static String getFormattedDate(String time) { long timeUnix = Long.parseLong(time); Date myDate = new Date(timeUnix * 1000); SimpleDateFormat simpleDateFormat = new SimpleDateFormat("MMM d yy"); return simpleDateFormat.format(myDate); } public static String getFormattedTime(String time) { long timeUnix = Long.parseLong(time); Date myDate = new Date(timeUnix * 1000); SimpleDateFormat simpleDateFormat = new SimpleDateFormat("hh:mm:ss"); return simpleDateFormat.format(myDate); }我从他们那里得到输出正确的,我需要的。
I get the correct output from them which I need.
Jul 12 11(date function) and 12:09:45(time function)我如何计算从该天,如何设置AM / PM与此有关。
How can I calculate days from this and how to set am/pm with this.
我想设置的时间与AM / PM如果是今天的日期,如果是年纪比显示日(周一,周二,周三等),如果它比一周比秀老更MMM d日YY
I am trying to set time with am/pm if it is today's date and if it is older than show the day(mon,tue,wed etc.) and if it is more than week old than show "MMM d yy".
推荐答案有关AM / PM符号:
For am/pm notation:
SimpleDateFormat dateFormat = new SimpleDateFormat("KK:mm:ss a"); return dateFormat.format(myDate);KK是的在凌晨小时/时(0-11)的,而HH是的中,日,小时(0-23)的
更多推荐
获得Android的格式化的日期和时间
发布评论