Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.util.Date;
- import java.text.DateFormat;
- import java.text.ParseException;
- import java.text.SimpleDateFormat;
- import java.util.Calendar;
- import java.util.Date;
- public class App {
- public static Date setDate(String dateStr, String format) {
- Date date = null;
- try {
- DateFormat dateFormat = new SimpleDateFormat(format);
- date = dateFormat.parse(dateStr);
- } catch (ParseException ex) {
- System.out.println("Exception during parse");
- }
- return date;
- }
- public static void main(String[] args) {
- Kot ratly = new Kot("Ratly");
- ratly.ileWazy(2);
- ratly.wlasciciel("Adam");
- Date date = setDate("1971/12/23 23:20:13", "yyyy/MM/dd HH:mm:ss");
- System.out.println("Kot urodzil sie: " + date);
- }
- }
- public class Kot {
- String imie;
- public Kot(String imie) {
- this.imie = imie;
- }
- public void Przedstaw_kota() {
- System.out.println("Kot nazywa sie " + imie);
- }
- public void ileWazy(int waga) {
- System.out.println(imie + " waży " + waga + " kg");
- }
- public void wlasciciel(String opiekun) {
- System.out.println("Opiekuje sie nim " + opiekun);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement