// 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);
}
}
}