一些时间处理的函数

// Decompiled by DJ v3.6.6.79 Copyright 2004 Atanas Neshkov  Date: 2005-3-22 9:18:19
// Home Page : http://members.fortunecity.com/neshkov/dj.html  - Check often for new version!
// Decompiler options: packimports(3)
// Source File Name:   DateUtil.java

package com.broadvision.commerce.marketmaker.util;

import com.broadvision.components.jsobject.BVI_DateTime;
import com.broadvision.util.BVLog;

public class DateUtil
{

    public DateUtil()
    {
    }

    public static String dateParseToString(BVI_DateTime datetime)
        throws Exception
    {
        String temp = datetime.getYear() + "-";
        if(datetime.getMonth() < 10)
            temp = temp + "0" + datetime.getMonth();
        else
            temp = temp + datetime.getMonth();
        if(datetime.getDay() < 10)
            temp = temp + "-0" + datetime.getDay();
        else
            temp = temp + "-" + datetime.getDay();
        if(datetime.getHour() < 10)
            temp = temp + " 0" + datetime.getHour();
        else
            temp = temp + " " + datetime.getHour();
        if(datetime.getMinute() < 10)
            temp = temp + ":0" + datetime.getMinute();
        else
            temp = temp + ":" + datetime.getMinute();
        if(datetime.getSecond() < 10)
            temp = temp + ":0" + datetime.getSecond();
        else
            temp = temp + ":"+datetime.getSecond();
        return temp;
    }

    public static String dateParseToStringNoTime(BVI_DateTime datetime)
        throws Exception
    {
        if(datetime == null)
        {
            return "";
        } else
        {
            String temp = datetime.getYear() + "/" + datetime.getMonth() + "/" + datetime.getDay();
            return temp;
        }
    }

    public static String getDistanceOfTwoTime(BVI_DateTime time1, BVI_DateTime time2)
    {
        String Temp = "";
        try
        {
            long time1L = time1.getUlongValue();
            long time2L = time2.getUlongValue();
            long distance = time1L - time2L;
            BVLog.error("time1----" + time1L);
            BVLog.error("time2----" + time2L);
            long second = distance % 60L;
            BVLog.error("second---" + second);
            BVLog.error("distance=======" + distance);
            distance /= 60L;
            long minute = distance % 60L;
            BVLog.error("distance=======" + distance);
            distance /= 60L;
            long hour = distance % 24;
            BVLog.error("distance=======" + distance);
            distance /= 24;
            long day = distance ;
            BVLog.error("distance=======" + distance);
            if(day > 0L)
                Temp = day + "/u5929" + hour + "/u5C0F/u65F6" + minute + "/u5206/u949F" + second + "/u79D2";
            else
            if(hour > 0L)
                Temp = hour + "/u5C0F/u65F6" + minute + "/u5206/u949F" + second + "/u79D2";
            else
            if(minute > 0L)
                Temp = minute + "/u5206/u949F" + second + "/u79D2";
            else
            if(second > 0L)
                Temp = second + "/u79D2";
        }
        catch(Exception e) { }
        return Temp;
    }

    public static BVI_DateTime stringParseToDate(String datetime)
        throws Exception
    {
        if(datetime == null)
        {
            return null;
        } else
        {
            BVLog.error("in date utility    ----" + datetime);
            BVLog.error("dt--------------------------year" + datetime.substring(0, 4));
            BVLog.error("dt--------------------------month" + datetime.substring(5, 7));
            BVLog.error("dt--------------------------day" + datetime.substring(8, 10));
            BVLog.error("dt--------------------------hour" + datetime.substring(11, 13));
            BVLog.error("dt--------------------------minute" + datetime.substring(14, 16));
            int year = Integer.parseInt(datetime.substring(0, 4));
            int month = Integer.parseInt(datetime.substring(5, 7));
            int day = Integer.parseInt(datetime.substring(8, 10));
            int hour = Integer.parseInt(datetime.substring(11, 13));
            int minute = Integer.parseInt(datetime.substring(14, 16));
            return new BVI_DateTime(year, month, day, hour, minute, 0, null);
        }
    }
}

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值