方法是:首先取得客户端的时区,之后得到服务器的本地时区,之后取得两个时区的差值,计算出相应的时间。
输入:服务器时间
输出:相应的客户端对应的时间
上代码:
#时间同步方法
#clint_timezone:client timezone
def formate_date_to_client_time_zone(clint_timezone,time)
diff=(clint_timezone-get_server_time_zone)
unless(clint_timezone.nil?)
time=time+diff*3600
end
return time
end
#获得本地时区
#return the server timezone
def get_server_time_zone
return Time.now.gmtoff/3600
end
Ruby:string to date Or date to string
#string to date
str="2009-02-02"
date=Date.strptime(str,"%Y-%m-%d")
#date to string:<br />date=Date.new(2009,2,2)
str=date.strftime("%Y-%m-%d")
Efflex 是一组由 Stephen Downs (aka “Tink”)开发的 Flex特效。
留个纪念,慢慢看
这里是demo
定义以下模式为有效的:
- john@hotmail.com
- john.doe@somewhere.com
- John Doe<john.doe@somewhere.com>
javascript的正则表达式为
var reEmail=/^(?:\w+\.?)*\w+@(?:\w+\.?)*\w+$/;
一直对RIA技术非常感兴趣,研究了一下Flex的事件机制,发现Flex的事件机制和Javascript很像,只不过更加严格。在Flex的事件机制中有一个比较重要的概念dispatchEvent,基本原理就是事件所在的容器类初始化的时候注册其事件监听函数。如果需要自己定义Event类型,需要将事件分发到事件队列中,也就是dispatchEvent。也就是你要手动找到自定义的事件的前一个事件,在这个结束的时候调用dispatchEvent(event),这个event就是你自定一个事件,这个事件(一个类)一定要继承flash.events.Event。
给个例子:
自定义的事件类:
public class AddressFormEvent extends Event
{
public static const SUBMIT:String = “submit”;
private var _data:AddressVO;
public function AddressFormEvent (eventName:String)
{
super (eventName);
}
public function set data (value:AddressVO):void
{
_data = value;
}
public function get data ():AddressVO
{
return _data;
}
}
在上一个事件结束的时候发布这个事件,下面这段代码就是找到上一个事件:
public class AddressFormClass extends Form
{
public var submitButton:Button;
public var nameInput:TextInput;
public var street:TextInput;
public var city:TextInput;
public var state:TextInput;
public var country:CountryComboBox;
public var otherInput:TextInput;
public var otherText:Text;
public function AddressFormClass():void
{
addEventListener(FlexEvent.CREATION_COMPLETE,creationCompleteHandler);
}
private function creationCompleteHandler(event:FlexEvent):void
{
submitButton.addEventListener(MouseEvent.CLICK,submitHandler);
}
private function submitHandler(event:MouseEvent):void //这个就是上一个事件的监听函数
{
// Gather the data for this form
var addressVO:AddressVO = new AddressVO();
addressVO.name = nameInput.text;
addressVO.street = street.text;
addressVO.city = city.text;
addressVO.state = state.text;
addressVO.country = country.selectedItem as String;
// 下面就是创建这个事件自定义事件,注意类型就是我们刚刚建的那个事件类。
var submitEvent:AddressFormEvent = new AddressFormEvent(AddressFormEvent.SUBMIT);
submitEvent.data = addressVO;
// Dispatch an event to signal that the form has been submitted
dispatchEvent(submitEvent); //这就是发布这个时间
}
}
在Application_context中引入名称空间,例子:<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:p="http://www.springframework.org/schema/p"
xmlns:aop="http://www.springframework.org/schema/aop"
xmlns:lang="http://www.springframework.org/schema/lang"
xmlns:context="http://www.springframework.org/schema/context"
xsi:schemaLocation="http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans-2.5.xsd
http://www.springframework.org/schema/lang
http://www.springframework.org/schema/lang/spring-lang-2.5.xsd
http://www.springframework.org/schema/aop
http://www.springframework.org/schema/aop/spring-aop-2.5.xsd
http://www.springframework.org/schema/context
http://www.springframework.org/schema/context/spring-context-2.5.xsd">
<context:component-scan base-package="bean"/>
<aop:aspectj-autoproxy/>
</beans>