Skip to content

Instantly share code, notes, and snippets.

@amake
Last active October 30, 2015 06:15
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save amake/eb5487bc2c87ee6eaed9 to your computer and use it in GitHub Desktop.
Save amake/eb5487bc2c87ee6eaed9 to your computer and use it in GitHub Desktop.
ISO 8601 Week Year Snippets
#!/usr/bin/env jython
# Test standard Java classes
from java.text import *
from java.lang import *
fmty = SimpleDateFormat('yyyy-MM-dd')
date = fmty.parse('2015-12-27', ParsePosition(0))
print fmty.format(date, StringBuffer(), FieldPosition(0)) # 2015-12-27
fmtY = SimpleDateFormat('YYYY-MM-dd')
print fmtY.format(date, StringBuffer(), FieldPosition(0)) # 2016-12-27
//: Playground - noun: a place where people can play
import UIKit
let fmty = NSDateFormatter()
fmty.dateFormat = "yyyy-MM-dd"
let date = fmty.dateFromString("2015-12-27")
fmty.stringFromDate(date!) // "2015-12-27"
let fmtY = NSDateFormatter()
fmtY.dateFormat = "YYYY-MM-dd"
fmtY.stringFromDate(date!) // "2016-12-27"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment