Skip to content

Instantly share code, notes, and snippets.

View jokamjohn's full-sized avatar
🏠
Working from home

John Kagga jokamjohn

🏠
Working from home
View GitHub Profile
@jokamjohn
jokamjohn / date.java
Last active January 11, 2016 20:26
Date and tine formatting
private String getCurrentTimeFormat(String timeFormat){
String time = "";
SimpleDateFormat df = new SimpleDateFormat(timeFormat);
Calendar c = Calendar.getInstance();
time = df.format(c.getTime());
return time;
}
//Add certain number of days to Today
import java.time.LocalDateTime;
import java.time.temporal.ChronoUnit;
public class DateTimeAPIStateless
{
public static void main( String[] args )
{
LocalDateTime timeInThePast = LocalDateTime.now().withDayOfMonth( 5 ).withYear( 2005 );
import java.time.Duration;
import java.time.Instant;
import java.time.LocalDate;
import java.time.LocalTime;
import java.time.Month;
import java.time.Period;
import java.time.ZoneId;
import java.time.temporal.ChronoUnit;
public class DurationsPeriodsAndInstants
import java.time.Clock;
import java.time.DayOfWeek;
import java.time.LocalDate;
import java.time.LocalDateTime;
import java.time.LocalTime;
import java.time.Month;
import java.time.Year;
import java.time.ZoneId;
import java.time.ZoneOffset;
import java.time.LocalDate;
import java.time.LocalDateTime;
import java.time.Month;
import java.time.format.DateTimeFormatter;
import java.time.format.DateTimeParseException;
import java.time.format.FormatStyle;
import java.util.Locale;
public class Parsing
{
import java.time.DayOfWeek;
import java.time.LocalDate;
import java.time.temporal.TemporalAdjusters;
public class TemporalAdjustersExamples
{
public static void main( String[] args )
{
/* using adjuster is possible to adjust a given date */
import java.time.DateTimeException;
import java.time.LocalDateTime;
import java.time.OffsetTime;
import java.time.ZoneId;
import java.time.ZoneOffset;
import java.time.ZonedDateTime;
public class TimeZones
{
@jokamjohn
jokamjohn / ParsePhpSetUp.txt
Last active January 12, 2016 20:45
Setting up parse for PhP
1. Install composer
2. Require the parse Sdk
3. Create an Application and auto load.
4. Create the app folder where all the class files are going to reside
"autoload": {
"psr-0": {
"app": ""
},
"files": [
@jokamjohn
jokamjohn / Routegroups.php
Created January 16, 2016 11:12
Route groups
Route::group(['prefix' => 'admin', 'namespace' => 'backend', 'before' => 'admin'], function()
{
// only /admin/ routes in here that will be in a namespace folder of "backend" with admin middleware
Route::resource('pages', 'PagesController'); // app/Http/controllers/backend/PagesController.php
});
@jokamjohn
jokamjohn / birthday.php
Created January 20, 2016 04:07
Create a birthday laravel
<div class="form-group {{ $errors->has('date_of_birth') ? 'has-error' : '' }}">
{{ Form::label('date_of_birth', 'Date of Birth', ['class' => 'control-label']) }}
<div class="form-inline">
{{ Form::selectRange('date_of_birth[day]', 1, 31, null, ['class' => 'form-control']) }}
{{ Form::selectMonth('date_of_birth[month]', null, ['class' => 'form-control']) }}
{{ Form::selectYear('date_of_birth[year]', date('Y') - 3, date('Y') - 16, null, ['class' => 'form-control']) }}
</div>
{{ $errors->first('date_of_birth', '<span class="help-block">:message</span>') }}
</div>