有没有像成才时间跨度在Android开发?跨度、时间、Android

2023-09-09 21:11:04 作者:Aurora.(极光)

我需要知道是否有类似的财产以后在Android开发时间跨度?

在C#中有像成才,我喜欢把它用在两个方面:

生成一个时间跨度,然后添加例如分钟,然后显示整个跨度 生成两个日期时间之间的时间跨度(什么是Android上相当于日期时间?) 解决方案

 众长addSeconds(长DT,INT秒)//方法及时补充秒
{

    日期申=新的日期(DT);
    日历CAL =新的GregorianCalendar();

    SimpleDateFormat的SDF =新的SimpleDateFormat(MM-DD-YYYY HH:MM:SS);
    sdf.setCalendar(卡);
    cal.setTimeInMillis(Dt.getTime());
    cal.add(Calendar.SECOND,秒);
    返回cal.getTime()的getTime()。

}
 

通的日期和时间以秒为单位,将返回修改的时间...

i need to know if there is somthing like a timespan in android development?

电影中时间跨度如何体现

in C# there is someting like and i like to use it in two ways:

generate a timespan and then add e.g. minutes and then display the whole span generate the timespan between two DateTime (what is the equivalent for DateTime in android?)

解决方案

public long addSeconds(long dt,int sec) //method to add seconds in time  
{

    Date Dt = new Date(dt);
    Calendar cal = new GregorianCalendar();

    SimpleDateFormat sdf = new SimpleDateFormat("MM-dd-yyyy HH:mm:ss");
    sdf.setCalendar(cal);
    cal.setTimeInMillis(Dt.getTime());
    cal.add(Calendar.SECOND, sec);
    return cal.getTime().getTime();

} 

pass date and time in sec, it will return modified time...