Most of the time, we need to send and receive SMS messages in our University/School Projects. I Used Java library called SMSLib for my above requirement. SMSlib is a Java library for sending and receiving SMS messages via a GSM modem or mobile phone. It also supports some bulk SMS operators, by implementing their HTTP interfaces.
For more Information - http://code.google.com/p/smslib/
Monday, September 28, 2009
Friday, September 18, 2009
Date Time Formats in Ruby
strftime( string ) method of the 'Date' class can use for that purpose..
eg - t = Time.now
t.strftime("%m/%d/%Y") #=> "19/09/2009"
t.strftime("%I:%M%p") #=> " 12:22PM"
Format Strings
%a - The abbreviated weekday name (``Sun'')
%A - The full weekday name (``Sunday'')
%b - The abbreviated month name (``Jan'')
%B - The full month name (``January'')
%c - The preferred local date and time representation
%d - Day of the month (01..31)
%H - Hour of the day, 24-hour clock (00..23)
%I - Hour of the day, 12-hour clock (01..12)
%j - Day of the year (001..366)
%m - Month of the year (01..12)
%M - Minute of the hour (00..59)
%p - Meridian indicator (``AM'' or ``PM'')
%S - Second of the minute (00..60)
%U - Week number of the current year,
starting with the first Sunday as the first
day of the first week (00..53)
%W - Week number of the current year,
starting with the first Monday as the first
day of the first week (00..53)
%w - Day of the week (Sunday is 0, 0..6)
%x - Preferred representation for the date alone, no time
%X - Preferred representation for the time alone, no date
%y - Year without a century (00..99)
%Y - Year with century
%Z - Time zone name
%% - Literal ``%'' character
eg - t = Time.now
t.strftime("%m/%d/%Y") #=> "19/09/2009"
t.strftime("%I:%M%p") #=> " 12:22PM"
Format Strings
%a - The abbreviated weekday name (``Sun'')
%A - The full weekday name (``Sunday'')
%b - The abbreviated month name (``Jan'')
%B - The full month name (``January'')
%c - The preferred local date and time representation
%d - Day of the month (01..31)
%H - Hour of the day, 24-hour clock (00..23)
%I - Hour of the day, 12-hour clock (01..12)
%j - Day of the year (001..366)
%m - Month of the year (01..12)
%M - Minute of the hour (00..59)
%p - Meridian indicator (``AM'' or ``PM'')
%S - Second of the minute (00..60)
%U - Week number of the current year,
starting with the first Sunday as the first
day of the first week (00..53)
%W - Week number of the current year,
starting with the first Monday as the first
day of the first week (00..53)
%w - Day of the week (Sunday is 0, 0..6)
%x - Preferred representation for the date alone, no time
%X - Preferred representation for the time alone, no date
%y - Year without a century (00..99)
%Y - Year with century
%Z - Time zone name
%% - Literal ``%'' character
Fixed Length Random numbers Ruby On Rails
Generating Random numbers in Ruby On Rails is very easy even without gems.
If u want 6 Digit random number try bellow code.
rand(999999).to_s.center(6, rand(9).to_s)
If you want 5 digit try bellow
rand(99999).to_s.center(5, rand(9).to_s)
Like this we can generate any number of digits random number..
If u want 6 Digit random number try bellow code.
rand(999999).to_s.center(6, rand(9).to_s)
If you want 5 digit try bellow
rand(99999).to_s.center(5, rand(9).to_s)
Like this we can generate any number of digits random number..
Subscribe to:
Posts (Atom)