Skip to content

Commit 1a7b06a

Browse files
committed
#11 format com 2 espacos ao inves de tab
1 parent d2aeac0 commit 1a7b06a

21 files changed

+342
-340
lines changed

src/org/j6toj8/localization/formats/dateformat/DateFormat_Instance.java

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -6,21 +6,21 @@
66

77
public class DateFormat_Instance {
88

9-
public static void main(String[] args) {
10-
// tag::code[]
11-
DateFormat dateInstance = DateFormat.getDateInstance();
12-
DateFormat timeInstance = DateFormat.getTimeInstance();
13-
DateFormat dateTimeInstance = DateFormat.getDateTimeInstance();
14-
DateFormat dateTimeLongInstance = DateFormat.getDateTimeInstance(DateFormat.LONG, DateFormat.LONG);
15-
DateFormat dateTimeUSInstance = DateFormat.getDateTimeInstance(DateFormat.LONG, DateFormat.LONG, Locale.US);
9+
public static void main(String[] args) {
10+
// tag::code[]
11+
DateFormat dateInstance = DateFormat.getDateInstance();
12+
DateFormat timeInstance = DateFormat.getTimeInstance();
13+
DateFormat dateTimeInstance = DateFormat.getDateTimeInstance();
14+
DateFormat dateTimeLongInstance = DateFormat.getDateTimeInstance(DateFormat.LONG, DateFormat.LONG);
15+
DateFormat dateTimeUSInstance = DateFormat.getDateTimeInstance(DateFormat.LONG, DateFormat.LONG, Locale.US);
1616

17-
Date date = new Date(1000000000000L); // data em quantidade de milissegundos desde 01/01/1970
18-
19-
System.out.println(dateInstance.format(date));
20-
System.out.println(timeInstance.format(date));
21-
System.out.println(dateTimeInstance.format(date));
22-
System.out.println(dateTimeLongInstance.format(date));
23-
System.out.println(dateTimeUSInstance.format(date));
24-
// end::code[]
25-
}
17+
Date date = new Date(1000000000000L); // data em quantidade de milissegundos desde 01/01/1970
18+
19+
System.out.println(dateInstance.format(date));
20+
System.out.println(timeInstance.format(date));
21+
System.out.println(dateTimeInstance.format(date));
22+
System.out.println(dateTimeLongInstance.format(date));
23+
System.out.println(dateTimeUSInstance.format(date));
24+
// end::code[]
25+
}
2626
}

src/org/j6toj8/localization/formats/dateformat/DateFormat_Parse.java

Lines changed: 19 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -5,24 +5,24 @@
55

66
public class DateFormat_Parse {
77

8-
public static void main(String[] args) {
9-
// tag::code[]
10-
DateFormat dateInstance = DateFormat.getDateInstance(DateFormat.SHORT);
11-
DateFormat timeInstance = DateFormat.getTimeInstance(DateFormat.SHORT);
12-
DateFormat dateTimeInstance = DateFormat.getDateTimeInstance(DateFormat.SHORT, DateFormat.SHORT);
8+
public static void main(String[] args) {
9+
// tag::code[]
10+
DateFormat dateInstance = DateFormat.getDateInstance(DateFormat.SHORT);
11+
DateFormat timeInstance = DateFormat.getTimeInstance(DateFormat.SHORT);
12+
DateFormat dateTimeInstance = DateFormat.getDateTimeInstance(DateFormat.SHORT, DateFormat.SHORT);
1313

14-
String date = "08/09/2001";
15-
String time = "22:46:40";
16-
String dateTime = "08/09/2001 22:46:40";
17-
18-
try {
19-
System.out.println(dateInstance.parse(date));
20-
System.out.println(timeInstance.parse(time));
21-
System.out.println(dateTimeInstance.parse(dateTime));
22-
System.out.println(dateTimeInstance.parse(date)); // exceção, pois date não tem hora
23-
} catch (ParseException e) {
24-
System.out.println(e.getMessage());
25-
}
26-
// end::code[]
27-
}
14+
String date = "08/09/2001";
15+
String time = "22:46:40";
16+
String dateTime = "08/09/2001 22:46:40";
17+
18+
try {
19+
System.out.println(dateInstance.parse(date));
20+
System.out.println(timeInstance.parse(time));
21+
System.out.println(dateTimeInstance.parse(dateTime));
22+
System.out.println(dateTimeInstance.parse(date)); // exceção, pois date não tem hora
23+
} catch (ParseException e) {
24+
System.out.println(e.getMessage());
25+
}
26+
// end::code[]
27+
}
2828
}

src/org/j6toj8/localization/formats/datetimeformatter/DateTimeFormatter_Custom.java

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -5,13 +5,13 @@
55

66
public class DateTimeFormatter_Custom {
77

8-
public static void main(String[] args) {
9-
// tag::code[]
10-
LocalDateTime localDT = LocalDateTime.of(2019, 8, 6, 11, 40);
11-
12-
DateTimeFormatter customFormatter = DateTimeFormatter.ofPattern("dd MM yy - HH mm ss");
13-
14-
System.out.println(localDT.format(customFormatter));
15-
// end::code[]
16-
}
8+
public static void main(String[] args) {
9+
// tag::code[]
10+
LocalDateTime localDT = LocalDateTime.of(2019, 8, 6, 11, 40);
11+
12+
DateTimeFormatter customFormatter = DateTimeFormatter.ofPattern("dd MM yy - HH mm ss");
13+
14+
System.out.println(localDT.format(customFormatter));
15+
// end::code[]
16+
}
1717
}

src/org/j6toj8/localization/formats/datetimeformatter/DateTimeFormatter_Error.java

Lines changed: 12 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -7,15 +7,16 @@
77

88
public class DateTimeFormatter_Error {
99

10-
public static void main(String[] args) {
11-
// tag::code[]
12-
LocalDate localDate = LocalDate.of(2019, 8, 6);
13-
LocalTime localTime = LocalTime.of(11, 40);
14-
LocalDateTime localDT = LocalDateTime.of(localDate, localTime);
15-
16-
System.out.println(localDate.format(DateTimeFormatter.ISO_LOCAL_DATE));
17-
System.out.println(localDT.format(DateTimeFormatter.ISO_LOCAL_DATE));
18-
System.out.println(localTime.format(DateTimeFormatter.ISO_LOCAL_DATE)); // lança exceção pois não possui campos de data
19-
// end::code[]
20-
}
10+
public static void main(String[] args) {
11+
// tag::code[]
12+
LocalDate localDate = LocalDate.of(2019, 8, 6);
13+
LocalTime localTime = LocalTime.of(11, 40);
14+
LocalDateTime localDT = LocalDateTime.of(localDate, localTime);
15+
16+
System.out.println(localDate.format(DateTimeFormatter.ISO_LOCAL_DATE));
17+
System.out.println(localDT.format(DateTimeFormatter.ISO_LOCAL_DATE));
18+
System.out.println(localTime.format(DateTimeFormatter.ISO_LOCAL_DATE)); // lança exceção pois não possui campos de
19+
// data
20+
// end::code[]
21+
}
2122
}

src/org/j6toj8/localization/formats/datetimeformatter/DateTimeFormatter_ErrorCustom.java

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -7,17 +7,17 @@
77

88
public class DateTimeFormatter_ErrorCustom {
99

10-
public static void main(String[] args) {
11-
// tag::code[]
12-
LocalDate localDate = LocalDate.of(2019, 8, 6);
13-
LocalTime localTime = LocalTime.of(11, 40);
14-
LocalDateTime localDT = LocalDateTime.of(localDate, localTime);
15-
16-
DateTimeFormatter formatter = DateTimeFormatter.ofPattern("HH mm ss");
17-
18-
System.out.println(localDT.format(formatter));
19-
System.out.println(localTime.format(formatter));
20-
System.out.println(localDate.format(formatter)); // lança exceção pois não possui campos de hora
21-
// end::code[]
22-
}
10+
public static void main(String[] args) {
11+
// tag::code[]
12+
LocalDate localDate = LocalDate.of(2019, 8, 6);
13+
LocalTime localTime = LocalTime.of(11, 40);
14+
LocalDateTime localDT = LocalDateTime.of(localDate, localTime);
15+
16+
DateTimeFormatter formatter = DateTimeFormatter.ofPattern("HH mm ss");
17+
18+
System.out.println(localDT.format(formatter));
19+
System.out.println(localTime.format(formatter));
20+
System.out.println(localDate.format(formatter)); // lança exceção pois não possui campos de hora
21+
// end::code[]
22+
}
2323
}

src/org/j6toj8/localization/formats/datetimeformatter/DateTimeFormatter_FormatStyle.java

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -6,19 +6,19 @@
66

77
public class DateTimeFormatter_FormatStyle {
88

9-
public static void main(String[] args) {
10-
// tag::code[]
11-
LocalDateTime localDT = LocalDateTime.of(2019, 8, 6, 11, 40);
12-
13-
DateTimeFormatter dateTimeShortFormatter = DateTimeFormatter.ofLocalizedDateTime(FormatStyle.SHORT);
14-
DateTimeFormatter dateTimeMediumFormatter = DateTimeFormatter.ofLocalizedDateTime(FormatStyle.MEDIUM);
15-
DateTimeFormatter dateShortFormatter = DateTimeFormatter.ofLocalizedDate(FormatStyle.SHORT);
16-
DateTimeFormatter timeShortFormatter = DateTimeFormatter.ofLocalizedTime(FormatStyle.SHORT);
17-
18-
System.out.println(localDT.format(dateTimeShortFormatter));
19-
System.out.println(localDT.format(dateTimeMediumFormatter));
20-
System.out.println(localDT.format(dateShortFormatter));
21-
System.out.println(localDT.format(timeShortFormatter));
22-
// end::code[]
23-
}
9+
public static void main(String[] args) {
10+
// tag::code[]
11+
LocalDateTime localDT = LocalDateTime.of(2019, 8, 6, 11, 40);
12+
13+
DateTimeFormatter dateTimeShortFormatter = DateTimeFormatter.ofLocalizedDateTime(FormatStyle.SHORT);
14+
DateTimeFormatter dateTimeMediumFormatter = DateTimeFormatter.ofLocalizedDateTime(FormatStyle.MEDIUM);
15+
DateTimeFormatter dateShortFormatter = DateTimeFormatter.ofLocalizedDate(FormatStyle.SHORT);
16+
DateTimeFormatter timeShortFormatter = DateTimeFormatter.ofLocalizedTime(FormatStyle.SHORT);
17+
18+
System.out.println(localDT.format(dateTimeShortFormatter));
19+
System.out.println(localDT.format(dateTimeMediumFormatter));
20+
System.out.println(localDT.format(dateShortFormatter));
21+
System.out.println(localDT.format(timeShortFormatter));
22+
// end::code[]
23+
}
2424
}

src/org/j6toj8/localization/formats/datetimeformatter/DateTimeFormatter_Inverted.java

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -6,17 +6,17 @@
66

77
public class DateTimeFormatter_Inverted {
88

9-
public static void main(String[] args) {
10-
// tag::code[]
11-
LocalDateTime localDT = LocalDateTime.of(2019, 8, 6, 11, 40);
12-
System.out.println(localDT);
13-
14-
String format = DateTimeFormatter.ISO_LOCAL_DATE_TIME.format(localDT);
15-
System.out.println(format);
16-
17-
TemporalAccessor parse = DateTimeFormatter.ISO_LOCAL_DATE_TIME.parse(format);
18-
System.out.println(parse);
19-
System.out.println(LocalDateTime.from(parse));
20-
// end::code[]
21-
}
9+
public static void main(String[] args) {
10+
// tag::code[]
11+
LocalDateTime localDT = LocalDateTime.of(2019, 8, 6, 11, 40);
12+
System.out.println(localDT);
13+
14+
String format = DateTimeFormatter.ISO_LOCAL_DATE_TIME.format(localDT);
15+
System.out.println(format);
16+
17+
TemporalAccessor parse = DateTimeFormatter.ISO_LOCAL_DATE_TIME.parse(format);
18+
System.out.println(parse);
19+
System.out.println(LocalDateTime.from(parse));
20+
// end::code[]
21+
}
2222
}

src/org/j6toj8/localization/formats/datetimeformatter/DateTimeFormatter_Locale.java

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -7,18 +7,18 @@
77

88
public class DateTimeFormatter_Locale {
99

10-
public static void main(String[] args) {
11-
// tag::code[]
12-
LocalDateTime localDT = LocalDateTime.of(2019, 8, 6, 11, 40);
13-
14-
DateTimeFormatter shortFormatter = DateTimeFormatter.ofLocalizedDateTime(FormatStyle.SHORT);
15-
DateTimeFormatter mediumFormatter = DateTimeFormatter.ofLocalizedDateTime(FormatStyle.MEDIUM);
16-
17-
shortFormatter = shortFormatter.withLocale(Locale.US);
18-
mediumFormatter = mediumFormatter.withLocale(Locale.US);
19-
20-
System.out.println(localDT.format(shortFormatter));
21-
System.out.println(localDT.format(mediumFormatter));
22-
// end::code[]
23-
}
10+
public static void main(String[] args) {
11+
// tag::code[]
12+
LocalDateTime localDT = LocalDateTime.of(2019, 8, 6, 11, 40);
13+
14+
DateTimeFormatter shortFormatter = DateTimeFormatter.ofLocalizedDateTime(FormatStyle.SHORT);
15+
DateTimeFormatter mediumFormatter = DateTimeFormatter.ofLocalizedDateTime(FormatStyle.MEDIUM);
16+
17+
shortFormatter = shortFormatter.withLocale(Locale.US);
18+
mediumFormatter = mediumFormatter.withLocale(Locale.US);
19+
20+
System.out.println(localDT.format(shortFormatter));
21+
System.out.println(localDT.format(mediumFormatter));
22+
// end::code[]
23+
}
2424
}

src/org/j6toj8/localization/formats/datetimeformatter/DateTimeFormatter_Parse.java

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -6,19 +6,19 @@
66

77
public class DateTimeFormatter_Parse {
88

9-
public static void main(String[] args) {
10-
// tag::code[]
11-
DateTimeFormatter customFormatter = DateTimeFormatter.ofPattern("dd MM yy - HH mm ss");
12-
DateTimeFormatter isoFormatter = DateTimeFormatter.ISO_LOCAL_DATE_TIME;
13-
DateTimeFormatter shortFormatter = DateTimeFormatter.ofLocalizedDateTime(FormatStyle.SHORT);
9+
public static void main(String[] args) {
10+
// tag::code[]
11+
DateTimeFormatter customFormatter = DateTimeFormatter.ofPattern("dd MM yy - HH mm ss");
12+
DateTimeFormatter isoFormatter = DateTimeFormatter.ISO_LOCAL_DATE_TIME;
13+
DateTimeFormatter shortFormatter = DateTimeFormatter.ofLocalizedDateTime(FormatStyle.SHORT);
1414

15-
LocalDateTime parseCustom = LocalDateTime.parse("06 08 19 - 11 40 00", customFormatter);
16-
LocalDateTime parseIso = LocalDateTime.parse("2019-08-06T11:40:00", isoFormatter);
17-
LocalDateTime parseShort = LocalDateTime.parse("06/08/19 11:40", shortFormatter);
18-
19-
System.out.println(parseCustom);
20-
System.out.println(parseIso);
21-
System.out.println(parseShort);
22-
// end::code[]
23-
}
15+
LocalDateTime parseCustom = LocalDateTime.parse("06 08 19 - 11 40 00", customFormatter);
16+
LocalDateTime parseIso = LocalDateTime.parse("2019-08-06T11:40:00", isoFormatter);
17+
LocalDateTime parseShort = LocalDateTime.parse("06/08/19 11:40", shortFormatter);
18+
19+
System.out.println(parseCustom);
20+
System.out.println(parseIso);
21+
System.out.println(parseShort);
22+
// end::code[]
23+
}
2424
}

src/org/j6toj8/localization/formats/datetimeformatter/DateTimeFormatter_Predefined.java

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -5,14 +5,14 @@
55

66
public class DateTimeFormatter_Predefined {
77

8-
public static void main(String[] args) {
9-
// tag::code[]
10-
LocalDateTime localDT = LocalDateTime.of(2019, 8, 6, 11, 40);
11-
System.out.println(localDT.format(DateTimeFormatter.ISO_LOCAL_DATE));
12-
System.out.println(localDT.format(DateTimeFormatter.ISO_LOCAL_TIME));
13-
System.out.println(localDT.format(DateTimeFormatter.ISO_LOCAL_DATE_TIME));
14-
System.out.println(localDT.format(DateTimeFormatter.ISO_ORDINAL_DATE));
15-
System.out.println(localDT.format(DateTimeFormatter.ISO_WEEK_DATE));
16-
// end::code[]
17-
}
8+
public static void main(String[] args) {
9+
// tag::code[]
10+
LocalDateTime localDT = LocalDateTime.of(2019, 8, 6, 11, 40);
11+
System.out.println(localDT.format(DateTimeFormatter.ISO_LOCAL_DATE));
12+
System.out.println(localDT.format(DateTimeFormatter.ISO_LOCAL_TIME));
13+
System.out.println(localDT.format(DateTimeFormatter.ISO_LOCAL_DATE_TIME));
14+
System.out.println(localDT.format(DateTimeFormatter.ISO_ORDINAL_DATE));
15+
System.out.println(localDT.format(DateTimeFormatter.ISO_WEEK_DATE));
16+
// end::code[]
17+
}
1818
}

0 commit comments

Comments
 (0)