import java.text.SimpleDateFormat
long lTime = new Date().time
String formattedDate = getUTCDateString(lTime)
println formattedDate
def getUTCDateString(long lTime)
{
Date lDate = new Date(lTime)
def cal = new GregorianCalendar(TimeZone.getTimeZone('UTC'))
cal.set(lDate[Calendar.YEAR],lDate[Calendar.MONTH],lDate[Calendar.DATE],lDate[Calendar.HOUR_OF_DAY],lDate[Calendar.MINUTE],lDate[Calendar.SECOND])
String formattedDate = new SimpleDateFormat("yyyy-mm-dd hh:mm").format(cal.time);
return formattedDate
}
Developer, Java Evangelist, extensively worked on Java, GWT, Flex, RIA technologies with enterprise frameworks. I have a privilege to conduct lot of Training/Coaching in Java Technologies, and to connect with real people.
Friday, March 19, 2010
Convert Date to String in groovy
Labels:
Dates in groovy,
Groovy goodness
Tuesday, March 9, 2010
Check if String is Number
String nbrStr = "30239023902390239023902323"
boolean b = nbrStr.isNumber()
assert b == true
boolean b = nbrStr.isNumber()
assert b == true
Labels:
Groovy goodness,
numbers in groovy
Groovy String to Integer
Converting a String to Number
String nbrStr = "100"
int i = nbrStr.toInteger()
assert i==100
String nbrStr = "100"
int i = nbrStr.toInteger()
assert i==100
Labels:
Groovy goodness,
String to Integer
Sunday, December 6, 2009
Converting String to Date in Groovy
Recently I was looking for a simple way to convert a String object to a Date format in groovy..
below is the example.
In groovy, its just a one liner to make this happen
String timeStampStr = "2009-12-01T12:36:22Z"
def strDate = new Date().parse("yyyy-MM-dd'T'HH:mm:ss'Z'",timeStampStr)
println strDate.
below is the example.
In groovy, its just a one liner to make this happen
String timeStampStr = "2009-12-01T12:36:22Z"
def strDate = new Date().parse("yyyy-MM-dd'T'HH:mm:ss'Z'",timeStampStr)
println strDate.
Labels:
Dates in groovy,
parsing dates in groovy
Sunday, November 1, 2009
Flex3 Animations
1. Easing Functions
Flex3 allows some cool effects using easing functions, you have to experience it.
Easing functions allows to give different effects to the components,
like a Bounce Effect
here is a good link of example based on that, thank you james for it
Good example to add the animations
Labels:
Flex Animations
Monday, September 14, 2009
Apache2.2 Proxy and Virtual Hosts
I created a Flex application using TWITTER Webservices, Since the CrossDomain policy of Twitter is very strong, My flex app was working on the development mode in flex builder but not outside.
Solution implement a Proxy.. Twitter API is a pure REST API , which uses GET as well as POST requests..
Following solution of Apache Proxy, works with the get request
ServerName mysite.com
ServerAlias tp.mysite.com
DocumentRoot "/var/www/"
AddHandler php5-script .php
AddType text/html .php
ProxyRequests off
Order Allow,Deny
Allow from all
ProxyPass /tproxy/ http://twitter.com/
ProxyPassReverse /tproxy/ http://twitter.com/
RequestHeader unset Accept-Encoding
#custom log file
LogLevel debug
ErrorLog /var/log/httpd/caw.local.error.log
CustomLog /var/log/httpd/caw.local.access.log combined
Labels:
Apache Proxy,
REST,
Twitter API,
Virtual Hosts
Wednesday, April 1, 2009
Securing Gitweb
We will secure Gitweb using Apache Module mod_auth_digest.
This document is based on following assumtions
Apache2 is run from /etc/apache2/
sudo htdigest /etc/apache2/passwd/digest private user2
Note : Omit the -c flag in order to add new user information to an existing password file.
ServerName gitdomain.com
DocumentRoot "/var/www/gitdomain.com/cgi-bin"
DirectoryIndex gitweb.cgi
SetEnv GITWEB_CONFIG /etc/gitweb.conf
ScriptAlias /cgi-bin/ /var/www/gitdomain.com/cgi-bin
Options Indexes FollowSymlinks ExecCGI
AuthType Digest
AuthName "private"
AuthUserFile /etc/apache2/passwd/digest
Require valid-user
SetHandler cgi-script
RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^.* /gitweb.cgi/$0 [L,PT]
Allow from all
# To debug rewrite rules, which were very painful to figure out
RewriteLog /var/log/apache2/rewrite_log
RewriteLogLevel 9
ErrorLog /var/log/apache2/gitweb
Suggested Reading
http://httpd.apache.org/docs/1.3/howto/auth.html
This document is based on following assumtions
- Apache2 is running and installed at /etc/apache2 folder
- gitdomain.com is already present and serving gitweb files
Apache2 is run from /etc/apache2/
- Lets created passwd file in
sudo htdigest /etc/apache2/passwd/digest private user2
Note : Omit the -c flag in order to add new user information to an existing password file.
- Enable the auth-digest sudo a2enmod auth-digest
- Edit the gitdomain.com as following
ServerName gitdomain.com
DocumentRoot "/var/www/gitdomain.com/cgi-bin"
DirectoryIndex gitweb.cgi
SetEnv GITWEB_CONFIG /etc/gitweb.conf
ScriptAlias /cgi-bin/ /var/www/gitdomain.com/cgi-bin
Options Indexes FollowSymlinks ExecCGI
AuthType Digest
AuthName "private"
AuthUserFile /etc/apache2/passwd/digest
Require valid-user
SetHandler cgi-script
RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^.* /gitweb.cgi/$0 [L,PT]
Allow from all
# To debug rewrite rules, which were very painful to figure out
RewriteLog /var/log/apache2/rewrite_log
RewriteLogLevel 9
ErrorLog /var/log/apache2/gitweb
- sudo service apache2 restart
Suggested Reading
http://httpd.apache.org/docs/1.3/howto/auth.html
Labels:
Apache2 Conf,
gitweb,
mod-auth digest,
Ubuntu
Subscribe to:
Posts (Atom)